-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <chrono> | ||
|
||
#include "Timing.hpp" | ||
|
||
// https://connect.microsoft.com/VisualStudio/feedback/details/719443 | ||
#ifdef _WIN32 | ||
# include <windows.h> | ||
static double s_freq; | ||
#endif | ||
|
||
void InitTiming() | ||
{ | ||
#ifdef _WIN32 | ||
uint64 freq; | ||
QueryPerformanceFrequency( (LARGE_INTEGER*)&freq ); | ||
s_freq = 1.0 / freq; | ||
#endif | ||
} | ||
|
||
uint64 GetTime() | ||
{ | ||
#ifdef _WIN32 | ||
uint64 ret; | ||
QueryPerformanceCounter( (LARGE_INTEGER*)&ret ); | ||
return uint64( ret * s_freq * 1000000 ); | ||
#else | ||
return std::chrono::time_point_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now() ).time_since_epoch().count(); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef __DARKRL__TIMING_HPP__ | ||
#define __DARKRL__TIMING_HPP__ | ||
|
||
#include "Types.hpp" | ||
|
||
void InitTiming(); | ||
uint64 GetTime(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters