We don't actually care that GetMicrosecondsSinceStart returns a time since

start; only that it's self-consistent.  If we want time since start, we
can record it ourself instead of making platform-specific code do it, and
only GetTimeSinceStart needs to do that, not RageTimers.
This commit is contained in:
Glenn Maynard
2005-07-19 03:09:20 +00:00
parent 71c765ba66
commit daf3688409
+10 -8
View File
@@ -29,29 +29,31 @@
#define TIMESTAMP_RESOLUTION 1000000 #define TIMESTAMP_RESOLUTION 1000000
const RageTimer RageZeroTimer(0,0); const RageTimer RageZeroTimer(0,0);
static uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart( true );
static void GetTime( unsigned &secs, unsigned &us, bool bAccurate ) static uint64_t GetTime( bool bAccurate )
{ {
// if !bAccurate, then don't call ArchHooks to find the current time. Just return the // if !bAccurate, then don't call ArchHooks to find the current time. Just return the
// last calculated time. GetMicrosecondsSinceStart is slow on some archs. // last calculated time. GetMicrosecondsSinceStart is slow on some archs.
static uint64_t usecs = 0; static uint64_t usecs = 0;
if( bAccurate ) if( bAccurate )
usecs = ArchHooks::GetMicrosecondsSinceStart( true ); usecs = ArchHooks::GetMicrosecondsSinceStart( true );
return usecs;
secs = unsigned(usecs / 1000000);
us = unsigned(usecs % 1000000);
} }
float RageTimer::GetTimeSinceStart( bool bAccurate ) float RageTimer::GetTimeSinceStart( bool bAccurate )
{ {
unsigned secs, us; uint64_t usecs = GetTime( bAccurate );
GetTime( secs, us, bAccurate ); usecs -= g_iStartTime;
return secs + (us / 1000000.0f); return usecs / 1000000.0f;
} }
void RageTimer::Touch() void RageTimer::Touch()
{ {
GetTime( this->m_secs, this->m_us, true ); uint64_t usecs = GetTime( true );
this->m_secs = unsigned(usecs / 1000000);
this->m_us = unsigned(usecs % 1000000);
} }
float RageTimer::Ago() const float RageTimer::Ago() const