If we look at the time of 'data_main' W:12 and 'data_main' W:13, the difference is 866,768 cycle.So we can conclude that "Delay(100000)" costs about 866,768 cycles. But it is a practical approach to use it for tracing code execution and timing as well.CYCCNTEN) which can be found in the Data Watchpoint and Trace register window.The CYCLECOUNTER is easy to use and provides precise measurements.Getting CYCLECOUNTER of two code points, and using the CPU clock, you can calculate the actual execution time.For example, if the CPU is running at 100MHz, you can divide by 100,000,000 to get the number of seconds passed. CYCLECOUNTER is the elapsed cycle from start, and CCSTEP is the elapsed cycle from the last displayed timing.However, you can measure the elapsed time easily and more precisely by using functionality available in your MCU and development tools.
Therefore, you should store the count value to a variable.
However, before trying to improve the performance of your code, you might want to measure the actual processing speed.
It is popular to use GPIO pins and oscilloscopes to measure the timing, and that is of course a valid and realistic approach.
It is mandatory for embedded systems to keep the execution time of a specific code shorter than the required time.
The processing speed can be of crucial importance for an application, and the speed can be improved by using new algorithms or applying compiler optimizations.