summaryrefslogtreecommitdiff
path: root/hammer/clock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hammer/clock.cpp')
-rw-r--r--hammer/clock.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/hammer/clock.cpp b/hammer/clock.cpp
new file mode 100644
index 0000000..cdb863e
--- /dev/null
+++ b/hammer/clock.cpp
@@ -0,0 +1,43 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include <stdafx.h>
+
+static double beginTime;
+
+
+double I_FloatTime( void )
+{
+ static double freq = 0.0;
+ static __int64 firstCount;
+ __int64 curCount;
+
+ if (freq == 0.0)
+ {
+ __int64 perfFreq;
+ QueryPerformanceFrequency( (LARGE_INTEGER*)&perfFreq );
+ QueryPerformanceCounter( (LARGE_INTEGER*)&firstCount );
+ freq = 1.0 / (double)perfFreq;
+ }
+
+ QueryPerformanceCounter ( (LARGE_INTEGER*)&curCount );
+ curCount -= firstCount;
+ double time = (double)curCount * freq;
+ return time;
+}
+
+
+void I_BeginTime( void )
+{
+ beginTime = I_FloatTime();
+}
+
+
+double I_EndTime( void )
+{
+ return ( I_FloatTime() - beginTime );
+}