PlatformIO Community

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 https://esp32.com/viewtopic.php?t=5174, 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 (https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/app_trace.html#app-trace-system-behaviour-analysis-with-segger-systemview).