Measuring CPU time


#1

Hi,
I am developing an algorithm which uses highly the math library and I’d like to measure the time it takes to execute. As a first aproximation I decided to send something through the serial interface, then execute the algorithm several times and after those executions print another thing onto the serial port. But it comes that the dump through the serial port is done when the algorithm finishes their executions so I can’t measure it properly. According to this behaviour i’m not sure if using a GPIO bringing it up and down each time the algorithm starts and finishes its execution and measuring it with an oscilloscope will be a nice a idea. Anyway, any of you have an idea to measure such a thing?

Greets

Daniel


#2

Hello Daniel,

Another way to measure time is to use the RTC or some internal timers. But in that way you will not have that good resolution but if you execute your algorithm enough then you might get an idea of the time it takes.

It’s an easy way to get access to time without involving external GPIOs or serial interfaces (that takes undefined time in the Wavecom software to execute).

/Snoooze


#3

Hi Daniel,
To check the time taken by your algorithm, you can perform the following steps:

  1. Subscribe to a tick timer (using adl_tmrSubscribe () API )as the first statement.
  2. Now perform the computations by the algorithm (i.e. execute your algorithm).
  3. When the algorithm finishes, call adl_tmrUnsubscribe () API.
  4. The return value of the timer will provide you the number of units of times that were remaining when the adl_tmrUnSubscribe () API was called. This would provide you a rough idea of the amout of time taken by your algorithm.
    You can increase the data to be processed by your algorigthm proportionately and depending upon the complexity of the algorithm (O(n), O(logn) ) etc, you can get an average time taken by the algoritm. This will also help in case, the algorithm finishes too fast (increasing the amount of data to process will also take this into account).

Best Regards,
OpenAT_Fan.


#4

thank you very much !

i will try both of the methods and I’ll tell you,
Thanks again,

Daniel