On Thu, Sep 26, 2013 at 9:36 PM,  <ignacio.mata...@gmail.com> wrote:
> hello,
>
> I tried several ways ( clock(), gettimeofday()..) but I can get the proper
> way to measure the elapsed time in microseconds.
>
> I am using eclipse to program in ansi c. Could anybody help me about how to
> measure the elapsed time in microsecond? Could it be possible to enclosed
> the code that I should use?
Ansi C or C++ (as in the title)?
In Ansi C it might look like this:

#include <sys/time.h>
#include <stdio.h>
// compile with: gcc -Wall gettimeofday.c -o gettimeofday
void main()
{
    float elapsed_time;
    struct timeval start_time, end_time;
    gettimeofday( &start_time, NULL );
    for (;;){
        gettimeofday( &end_time, NULL );
        elapsed_time = end_time.tv_sec - start_time.tv_sec + (
end_time.tv_usec - start_time.tv_usec ) / 1e6;
        printf( "sec: %g          \r", elapsed_time );
        }
}

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to