[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Inaccurate time measurements. Help Please
- Date: Sun, 7 Mar 2004 09:24:47 -0800
- From: frank95758 at frontiernet.net (frank95758 at frontiernet.net)
- Subject: Inaccurate time measurements. Help Please
> To check whether the times are reliable, I did
> the following.
> print "Time Measurement starts\n"
> Do gettimeofday()
> Do gettimeofday() again
> Print the difference between the two times.
> 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
Hope this helps.