[Base] Optional raw Clock source.

New cvar clock_source_raw allows to use the cpu cycle counter itself as an alternative time source, if system timing resolution is to low and causes problems.
This commit is contained in:
Joel Linn
2019-11-20 22:08:41 +01:00
committed by Rick Gibbed
parent f88d46cead
commit 15d422d988
5 changed files with 145 additions and 11 deletions

View File

@@ -13,13 +13,13 @@
namespace xe {
uint64_t Clock::host_tick_frequency() {
uint64_t Clock::host_tick_frequency_platform() {
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
return frequency.QuadPart;
}
uint64_t Clock::QueryHostTickCount() {
uint64_t Clock::host_tick_count_platform() {
LARGE_INTEGER counter;
uint64_t time = 0;
if (QueryPerformanceCounter(&counter)) {
@@ -35,7 +35,7 @@ uint64_t Clock::QueryHostSystemTime() {
}
uint64_t Clock::QueryHostUptimeMillis() {
return QueryHostTickCount() / (host_tick_frequency() / 1000);
return host_tick_count_platform() * 1000 / host_tick_frequency_platform();
}
} // namespace xe