How can I measure the runtime of the code?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
robu
Posts: 25
Joined: Sat Nov 24, 2012 3:39 pm

How can I measure the runtime of the code?

Post by robu »

Hi,

I'm using the following code to measure the runtime of my code

Code: Select all

start = chTimeNow();
my code
end = chTimeNow();
chprintf((BaseSequentialStream *) &SD1, "%fus\r\n", RTT2US(end - start));

I'm reciving 19 or 20 us, I never expected that my code is so fast. Am I measuring the running time in the right way?

Thanks,
Robert
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: How can I measure the runtime of the code?

Post by Tectu »

Your code seems right to me on the first look. However, can you paste the code you execute?


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: How can I measure the runtime of the code?

Post by Giovanni »

The system timer has a resolution of 1uS, the RTT macro is used with the RT counter that is optionally implemented in the HAL driver (halGetCounterValue() function), I think it is not present in the RPI port, you should confirm with the author.

Giovanni
Post Reply