Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: runtime/bin/utils_macos.cc

Issue 1563473002: Refactor monotonic clock interface and use raw tick values in stopwatch (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/stopwatch.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/utils_macos.cc
diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc
index e4d718ff2c03b3fa51d8fbe18c6211f812201d00..5ac414fb9b5ca399e7970403e4ba28d415d68365 100644
--- a/runtime/bin/utils_macos.cc
+++ b/runtime/bin/utils_macos.cc
@@ -74,7 +74,11 @@ bool ShellUtils::GetUtf8Argv(int argc, char** argv) {
return false;
}
+static mach_timebase_info_data_t timebase_info;
+
void TimerUtils::InitOnce() {
+ kern_return_t kr = mach_timebase_info(&timebase_info);
+ ASSERT(KERN_SUCCESS == kr);
}
int64_t TimerUtils::GetCurrentMonotonicMillis() {
@@ -97,17 +101,7 @@ int64_t TimerUtils::GetCurrentMonotonicMicros() {
origin += boottime.tv_usec;
return now - origin;
#else
- static mach_timebase_info_data_t timebase_info;
- if (timebase_info.denom == 0) {
- // Zero-initialization of statics guarantees that denom will be 0 before
- // calling mach_timebase_info. mach_timebase_info will never set denom to
- // 0 as that would be invalid, so the zero-check can be used to determine
- // whether mach_timebase_info has already been called. This is
- // recommended by Apple's QA1398.
- kern_return_t kr = mach_timebase_info(&timebase_info);
- ASSERT(KERN_SUCCESS == kr);
- }
-
+ ASSERT(timebase_info.denom != 0);
// timebase_info converts absolute time tick units into nanoseconds. Convert
// to microseconds.
int64_t result = mach_absolute_time() / kNanosecondsPerMicrosecond;
« no previous file with comments | « no previous file | runtime/lib/stopwatch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698