cancel
Showing results for 
Search instead for 
Did you mean: 

Functions execution times measurment

mailmail9116
Associate II
Posted on January 20, 2013 at 08:38

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

Michael
3 REPLIES 3
Posted on January 20, 2013 at 14:05

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.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=11943&RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Duration%20of%20FLOAT%20operations

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mailmail9116
Associate II
Posted on January 20, 2013 at 15:55

Hi,

and how about using the systick interrupt? it seems to be working just fine for me,is it a good practice?

Posted on January 20, 2013 at 16:11

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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..