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?