gettimeofday() inaccuracy
Posted: Sat Mar 17, 2012 7:32 am
Hey folks,
I'm in search of a microsecond- or nanosecond-accurate timer for a project but the microsecond field returned from gettimeofday() is completely bogus. As a test I wrote a simple loop that calls gettimeofday() 100 times and prints the results each time before quitting.
Here's what it looks like in Windows (truncated for brevity, MinGW used):
This is what it looks like when ran on both a physical Wii and in the Dolphin emulator with any of the CPU options:
They are both in the order that they were executed. The Wii version doesn't just fail but it also bounces around with seemingly random numbers in the microsecond slot.
Is there anything that I can do either to fix gettimeofday() or replace it with another high-granularity timer?
Thanks!
-ObsidianX
I'm in search of a microsecond- or nanosecond-accurate timer for a project but the microsecond field returned from gettimeofday() is completely bogus. As a test I wrote a simple loop that calls gettimeofday() 100 times and prints the results each time before quitting.
Here's what it looks like in Windows (truncated for brevity, MinGW used):
Code: Select all
1331965376; 300935
1331965376; 301935
1331965376; 302935
1331965376; 303935
1331965376; 304935
1331965376; 305935
Code: Select all
1331930967; 454
1331930967; 192
1331930967; 30
1331930967; 304
1331930967; 416
1331930967; 154
Is there anything that I can do either to fix gettimeofday() or replace it with another high-granularity timer?
Thanks!
-ObsidianX