mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-03 05:49:41 +03:00
1
This commit is contained in:
43
hammer/clock.cpp
Normal file
43
hammer/clock.cpp
Normal file
@@ -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 );
|
||||
}
|
||||
Reference in New Issue
Block a user