[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

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2017 Ben Vanik. All rights reserved. *
* Copyright 2019 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -14,14 +14,14 @@
namespace xe {
uint64_t Clock::host_tick_frequency() {
uint64_t Clock::host_tick_frequency_platform() {
timespec res;
clock_getres(CLOCK_MONOTONIC_RAW, &res);
return uint64_t(res.tv_sec) + uint64_t(res.tv_nsec) * 1000000000ull;
}
uint64_t Clock::QueryHostTickCount() {
uint64_t Clock::host_tick_count_platform() {
timespec res;
clock_gettime(CLOCK_MONOTONIC_RAW, &res);
@@ -40,7 +40,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