View unanswered posts | View active topics It is currently Thu Oct 23, 2014 6:08 pm



Reply to topic  [ 3 posts ] 
 gettimeofday() inaccuracy 
Author Message

Joined: Fri Oct 03, 2008 4:18 am
Posts: 4
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):

Code:
1331965376; 300935
1331965376; 301935
1331965376; 302935
1331965376; 303935
1331965376; 304935
1331965376; 305935


This is what it looks like when ran on both a physical Wii and in the Dolphin emulator with any of the CPU options:

Code:
1331930967; 454
1331930967; 192
1331930967; 30
1331930967; 304
1331930967; 416
1331930967; 154


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


Sat Mar 17, 2012 7:32 am
Profile

Joined: Fri Oct 03, 2008 4:18 am
Posts: 4
For the record, after much Google'ing around I finally found that if I use gettime() and diff_usec(start_time, current_time) I can get an elapsed time in microseconds.
There are various diff_ functions for different time measurements available.
All are found in <ogc/lwp_watchdog.h>


Thu Mar 22, 2012 12:54 am
Profile

Joined: Thu Dec 10, 2009 9:26 am
Posts: 37
It looks like __libogc_gettod_r() in timesupp.c should be using tick_to_microsecs() instead of tick_microsecs().


Sun Apr 01, 2012 1:52 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads