<div dir="ltr">Hi Martin, <div><br></div><div>thank you for the explanation. </div><div><br></div><div>best, </div></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 August 2017 at 16:54, Martin Stein <span dir="ltr"><<a href="mailto:martin.stein@...1..." target="_blank">martin.stein@...1...</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Mohammad,<br>
<span class=""><br>
Am 02.08.2017 um 16:36 schrieb Mohammad Hamad:<br>
> I am trying to measure the execution time of a function on RPI model B.<br>
><br>
> I used the "Trace::timestamp" function to calculate it. In the same<br>
> time, I used the elapsed_ms() function to compare with it.<br>
><br>
> as I understood, the "Trace::timestamp" function gives the performance<br>
> counter. Dose the elapsed_ms function provide the execution time of the<br>
> method in milliseconds?<br>
<br>
</span>Yes, 'Trace::timestamp' returns the ARM performance-counter value on<br>
RPI. You can find the implementation details in [1]. And no,<br>
'elapsed_ms()' does not return the execution time of any function but<br>
the time elapsed since the creation of the Timer::Connection on which<br>
you call it. More precisely the point in time when the Timer server<br>
initializes the 'elapsed_ms' counting for the Connection. So, the best<br>
way to use it would be by creating the delta of two subsequent calls.<br>
<span class=""><br>
> During the measurements, I got some related numbers in somehow. For an<br>
> example, the average of elapsed_ms() was 2,18 and the average of<br>
> performance counter is 24825,02<br>
><br>
> How could I convert the delta of the performance counter to<br>
> milliseconds? I guess I need to divide by the CPU_cycle.<br>
<br>
</span>The performance counter on ARMv6 platforms like RPI is configured to<br>
count every 64th CPU cycle. So, the formula for the performance counter is:<br>
<br>
PERF_COUNTER = MS * 1000 * CPU_FREQ / 64<br>
<br>
And thus, the translation to milliseconds would look like this:<br>
<br>
MS = PERF_COUNTER * 64 / ( CPU_FREQ * 1000 )<br>
<span class=""><br>
> If yes, does the cpu_cycle specified or modified by the Genode? How can<br>
> I get this value?<br>
<br>
</span>AFAIK, the RPI model B has a CPU frequency of 700 Mhz and Genode does<br>
not adapt this. Only one sidenote at this point: Be aware that the ARM<br>
performance counter does not necesarily increase constantly over time.<br>
AFAIK, it does for the RPI, but there are counter examples. For<br>
instance, on all ARMv7 platforms, we use the WFI (wait for interrupt)<br>
instruction on idle [2] to save energy and thereby pause the counter for<br>
an unforeseeable amount of time. But, as I said, for RPI, I do not know<br>
any reason why the counter shouldn't be constant over time.<br>
<br>
I hope this helps you...<br>
<br>
Cheers,<br>
Martin<br>
<br>
[1] base-hw/src/core/spec/arm_v6/<wbr>perf_counter.cc<br>
[2] base-hw/src/core/spec/arm_v7/<wbr>cpu_support.h<br>
<br>
------------------------------<wbr>------------------------------<wbr>------------------<br>
Check out the vibrant tech community on one of the world's most<br>
engaging tech sites, Slashdot.org! <a href="http://sdm.link/slashdot" rel="noreferrer" target="_blank">http://sdm.link/slashdot</a><br>
______________________________<wbr>_________________<br>
genode-main mailing list<br>
<a href="mailto:genode-main@lists.sourceforge.net">genode-main@...172...<wbr>net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/genode-main" rel="noreferrer" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/genode-main</a><br>
</blockquote></div><br></div>