OSX ArchHooks::GetMicrosecondsSinceStart

This commit is contained in:
Glenn Maynard
2004-06-11 01:06:32 +00:00
parent 71797f7383
commit bd6899b9bf
@@ -14,6 +14,7 @@
#include <mach/thread_act.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/time.h>
/* You would think that these would be defined somewhere. */
enum
@@ -343,6 +344,20 @@ void ArchHooks_darwin::ExitTimeCriticalSection()
LOG->Warn( "Time-critical section lasted for %f", fTimeCritLen );
}
static int64_t GetMicrosecondsSinceEpoch()
{
struct timeval tv;
gettimeofday( &tv, NULL );
return int64_t(tv.tv_sec) * 1000000 + int64_t(tv.tv_usec);
}
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
{
static int64_t iStartTime = GetMicrosecondsSinceEpoch();
return GetMicrosecondsSinceEpoch() - iStartTime;
}
/*
* (c) 2003-2004 Steve Checkoway
* All rights reserved.