2013-01-19 11:38 PM
Hi,
I want to measure the preformance of my program,by measuring the execution time of various functions ,as the atollic toolchain dont have functions like : clock_gettime ,that is somewhat accurate to the milli second resolution , i am looking for alternatives . Any ideas? I was thinking maybe use the systick ,set it to 1 milli second interrupts and measure with it. Thanks Michael2013-01-20 05:05 AM
For the STM32 F1/F2/F3/F4 the best solution would be to use the core cycle counter in the Trace Unit (DWT_CYCCNT) which runs at SYSCLK, so plenty of granularity there. Beyond the scope of the counter you'd need to set up a 16 or 32-bit counter at a synchronous but slower rate. The core count can still provide a fractional measurement component.
2013-01-20 06:55 AM
Hi,
and how about using the systick interrupt? it seems to be working just fine for me,is it a good practice?2013-01-20 07:11 AM
It's a bit course for my taste, but depends on the accuracy you need. If you're timing over minutes or multiple seconds, then a millisecond resolution will suffice.
For raw computations, or tight loops, instruction level timing is probably more helpful in terms of optimizing and algorithm testing. Depends if your issue is cpu bound, or peripheral/io bound.