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

Unified Diff: runtime/vm/os_android.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
Index: runtime/vm/os_android.cc
diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc
index 5c09baf03571c4e6599806a81fda95d38dc0334b..9dcd09ece5e6a1af93c4985b4ed285cf743f1d0d 100644
--- a/runtime/vm/os_android.cc
+++ b/runtime/vm/os_android.cc
@@ -179,20 +179,32 @@ int64_t OS::GetCurrentTimeMicros() {
}
-int64_t OS::GetCurrentMonotonicMicros() {
+int64_t OS::GetCurrentMonotonicTicks() {
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
UNREACHABLE();
return 0;
}
- // Convert to microseconds.
+ // Convert to nanoseconds.
int64_t result = ts.tv_sec;
- result *= kMicrosecondsPerSecond;
- result += (ts.tv_nsec / kNanosecondsPerMicrosecond);
+ result *= kNanosecondsPerSecond;
+ result += ts.tv_nsec;
return result;
}
+int64_t OS::GetCurrentMonotonicFrequency() {
+ return kNanosecondsPerSecond;
+}
+
+
+int64_t OS::GetCurrentMonotonicMicros() {
+ int64_t ticks = GetCurrentMonotonicTicks();
+ ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond);
+ return ticks / kNanosecondsPerMicrosecond;
+}
+
+
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_linux.cc » ('j') | runtime/vm/os_macos.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698