ESP32 & PIO debug - cpu time

I am doing PIO debug using ESP32 devmodule and FT2232H minimodule.

I want to know the CPU time to measure the processing time of the function.

How can I check the number of CPU cycles?

You don’t even need a debugger tool to see this, just read the number of cycles (CCOUNT / clock count register) using the intrinsic XTensa CPU functions before and after the function execution. This was already answered in Function for reading cycle count of CPU clock - ESP32 Forum, see the function

or for Arduino

I.e. just call

uint32_t cyclesNow = ESP.getCycleCount();

If you’re looking for a more in-depth JTAG tracing of the CPU core instead of explicitly putting in the code, then, as the ESP-IDF documentation says, use external tools like SEGGER SystemView (Application Level Tracing library - ESP32 - — ESP-IDF Programming Guide latest documentation).