Inaccurate time measurements. Help Please

frank95758 at frank95758 at
Sun Mar 7 17:24:47 UTC 2004

> verification:
>       To check whether the times are reliable, I did
> the following.
>          print "Time Measurement starts\n"
>          Do gettimeofday()
>          sleep(20)
>          Do gettimeofday() again
>          Print the difference between the two times.
> Problem:
>       By doing the above verification, the printed
> result clearly shows 20000001 microseconds, but the
> actual time elapsed (measured with my wrist watch)
> between the two prints is more than 140 seconds.
> Please help in getting accurate measurement of time.
I am new to rtems (actully just starting building the source).  So not
sure there are any issues with the gettimeofday or sleep routines. 
Here is my $0.02 on the timing verification.

When you time with your wrist watch, you are also timing the two print
calls.  One way to verify your print statement (or the I/O) didn't mess
up your timing is to do a dummy test without the gettimeofday and
sleep(20) statement such as:
print "Time Measurement start\n";
print "Time Measurement stop\n";

If this takes 120 seconds (by your writs watch), then you know your
problem is the print routines or I/O related.

If not, you can then repeat your test but without the sleep(20) to see
if you got a reasonable number (i.e. no more than a second from last
print timing) just to check on the gettimeofday calls.

I am sure you will get a shorter answer from someone that knows the
rtems internals.

Hope this helps.


More information about the users mailing list