diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/clock.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'hammer/clock.cpp')
| -rw-r--r-- | hammer/clock.cpp | 43 |
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 ); +} |