Re: Time measuring on an SBC2440-II (ARM920T) board

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


>I try to measure the execution time of a function in a c program. With
>the header "sys/time.h" it is possible to measure the time in
>microseconds, but I need more precise information.

>Is there a way to read out the clock count of the processor or to
>access the timers under arm linux?

To get the accurate time consumed by the function use clock() instead of
gettimeifday().
gettimeofday() gives you wall clock time elapsed instead of execution time
of a function.
To get the value in micro sec use below code

pseudo code to get function() execution time
------------------------------------------------------
#include <clock.h>
#define NLOOP 1000000
clock_t c0, c1;
double i, time_in_micro;

co =clock();

for(i=0; i< NLOOP; i++)
      function();

c1 = clock();

time_in_micro = (c1 - c0)*(1/CLOCK_PER_SEC);

--------------------------------------------------------

Hope this helps you.
Ravi Sankar Guntur.

On Fri, Nov 28, 2008 at 8:10 PM, Malte Wienecke <Malte.Wienecke@xxxxxx>wrote:

> Hi,
>
> I try to measure the execution time of a function in a c program. With
> the header "sys/time.h" it is possible to measure the time in
> microseconds, but I need more precise information.
>
> Is there a way to read out the clock count of the processor or to
> access the timers under arm linux?
>
> I hope you can help me.
>
>
> -------------------------------------------------------------------
> List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
> FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
> Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php
>



-- 
--,
BR,
Ravi Sankar Guntur.
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php

[Linux ARM]     [Linux ARM MSM]     [Linux ARM Kernel]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

Add to Google Follow linuxarm on Twitter