| Index: runtime/vm/os_win.cc
|
| diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc
|
| index 917ee6f24e7d01debcdc783ced480090aabf8e6c..551607de192d6bde5c6830409c6723edfadbe855 100644
|
| --- a/runtime/vm/os_win.cc
|
| +++ b/runtime/vm/os_win.cc
|
| @@ -123,7 +123,8 @@ int64_t OS::GetCurrentTimeMicros() {
|
|
|
| static int64_t qpc_ticks_per_second = 0;
|
|
|
| -int64_t OS::GetCurrentMonotonicMicros() {
|
| +
|
| +int64_t OS::GetCurrentMonotonicTicks() {
|
| if (qpc_ticks_per_second == 0) {
|
| // QueryPerformanceCounter not supported, fallback.
|
| return GetCurrentTimeMicros();
|
| @@ -132,11 +133,27 @@ int64_t OS::GetCurrentMonotonicMicros() {
|
| LARGE_INTEGER now;
|
| QueryPerformanceCounter(&now);
|
| int64_t qpc_value = static_cast<int64_t>(now.QuadPart);
|
| +}
|
| +
|
| +
|
| +int64_t OS::GetCurrentMonotonicFrequency() {
|
| + if (qpc_ticks_per_second == 0) {
|
| + // QueryPerformanceCounter not supported, fallback.
|
| + return kMicrosecondsPerSecond;
|
| + }
|
| + return qpc_ticks_per_second;
|
| +}
|
| +
|
| +
|
| +int64_t OS::GetCurrentMonotonicMicros() {
|
| + int64_t ticks = GetCurrentMonotonicTicks();
|
| + int64_t frequency = GetCurrentMonotonicFrequency();
|
| +
|
| // Convert to microseconds.
|
| - int64_t seconds = qpc_value / qpc_ticks_per_second;
|
| - int64_t leftover_ticks = qpc_value - (seconds * qpc_ticks_per_second);
|
| + int64_t seconds = ticks / frequency;
|
| + int64_t leftover_ticks = ticks - (seconds * frequency);
|
| int64_t result = seconds * kMicrosecondsPerSecond;
|
| - result += ((leftover_ticks * kMicrosecondsPerSecond) / qpc_ticks_per_second);
|
| + result += ((leftover_ticks * kMicrosecondsPerSecond) / frequency);
|
| return result;
|
| }
|
|
|
|
|