If the debug tool does not have the feature for counting the number of cycles (for example, PSoC Creator and ModusToolbox), there are several ways to measure with the timer as follows：
GPIO is output as High / Low and measured with an oscilloscope. It is effective when measuring a long time.
It is effective when simply measuring the number of cycles, but it may be used in other time-related APIs.
It is an ARM emulation function for cortex M3/M4 and can be used when the debugger is not using it.
Slower than CPU frequency.
Available on ARM Cortex A and R, but not Cortex M.
In this time, I attached a sample of Cycle measurement using DWT which would be not used often. Please use it if you are interested.
Note: DWT can only be measured from Debugging of PSoC Creator.
The program just calls the DWT counter value for the function you want to measure in main_cm4.c based on the sample program of "CE223001-PSoC 6 MCU UART printf" and calculates the difference. the key points of this program as below.
#define DWT_CTRL 0xE0001000
#define DWT_CYCLE_COUNT 0xE0001004
(*(int*)DWT_CTRL) |= 0x1; // Counter enable
(*(int*)DWT_CYCLE_COUNT) = 0; // Set counter to Zero
Call DWT counter：
SysCntVal = (*(int*)DWT_CYCLE_COUNT);
CyDelay(10); // API to be measured
SysCntVal = (*(int*)DWT_CYCLE_COUNT) - SysCntVal;
I checked this program on PSoC 6 BLE Pioneer Kit CY8CKIT-062-BLE.
This feature is on ARM Cortex M3 and M4.
Unfortunately, PSoC 4 is not available.
I am not sure about PSoC 5 because I don't have the board.
I would be grateful if someone could confirm with PSoC 5.
Originally, DWT is a function used by the debug tool. It is used for cycle measurement between breakpoints and profiling functions, and is used by third party debug tools.
I hope Modus Toolbox and PSoC Creator will be able to display cycle counts using this feature.