execution time on RPI.

Martin Stein martin.stein at ...1...
Thu Aug 3 12:58:00 CEST 2017


Hi Mohammad,

Am 02.08.2017 um 16:36 schrieb Mohammad Hamad:
> I am trying to measure the execution time of a function on RPI model B. 
> 
> I used the "Trace::timestamp" function to calculate it. In the same
> time, I used the elapsed_ms() function to compare with it.
> 
> as I understood, the "Trace::timestamp" function gives the performance
> counter.  Dose the elapsed_ms function provide the execution time of the
> method in milliseconds? 

Yes, 'Trace::timestamp' returns the ARM performance-counter value on
RPI. You can find the implementation details in [1]. And no,
'elapsed_ms()' does not return the execution time of any function but
the time elapsed since the creation of the Timer::Connection on which
you call it. More precisely the point in time when the Timer server
initializes the 'elapsed_ms' counting for the Connection. So, the best
way to use it would be by creating the delta of two subsequent calls.

> During the measurements, I got some related numbers in somehow. For an
> example, the average of  elapsed_ms() was 2,18 and the  average of
> performance counter is 24825,02
>
> How could I convert the delta of the performance counter to
> milliseconds? I guess I need to divide by the CPU_cycle.

The performance counter on ARMv6 platforms like RPI is configured to
count every 64th CPU cycle. So, the formula for the performance counter is:

PERF_COUNTER = MS * 1000 * CPU_FREQ / 64

And thus, the translation to milliseconds would look like this:

MS = PERF_COUNTER * 64 / ( CPU_FREQ * 1000 )

>  If yes, does the cpu_cycle specified or modified by the Genode? How can
>  I get this value?

AFAIK, the RPI model B has a CPU frequency of 700 Mhz and Genode does
not adapt this. Only one sidenote at this point: Be aware that the ARM
performance counter does not necesarily increase constantly over time.
AFAIK, it does for the RPI, but there are counter examples. For
instance, on all ARMv7 platforms, we use the WFI (wait for interrupt)
instruction on idle [2] to save energy and thereby pause the counter for
an unforeseeable amount of time. But, as I said, for RPI, I do not know
any reason why the counter shouldn't be constant over time.

I hope this helps you...

Cheers,
Martin

[1] base-hw/src/core/spec/arm_v6/perf_counter.cc
[2] base-hw/src/core/spec/arm_v7/cpu_support.h




More information about the users mailing list