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

Side by Side Diff: runtime/vm/os_android.cc

Issue 1504523002: Use a monotonic clock in the implementation of Stopwatch. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <android/log.h> // NOLINT 10 #include <android/log.h> // NOLINT
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // gettimeofday has microsecond resolution. 172 // gettimeofday has microsecond resolution.
173 struct timeval tv; 173 struct timeval tv;
174 if (gettimeofday(&tv, NULL) < 0) { 174 if (gettimeofday(&tv, NULL) < 0) {
175 UNREACHABLE(); 175 UNREACHABLE();
176 return 0; 176 return 0;
177 } 177 }
178 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 178 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
179 } 179 }
180 180
181 181
182 int64_t OS::GetCurrentTraceMicros() { 182 int64_t OS::GetCurrentMonotonicMicros() {
183 struct timespec ts; 183 struct timespec ts;
184 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { 184 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
185 UNREACHABLE(); 185 UNREACHABLE();
186 return 0; 186 return 0;
187 } 187 }
188 // Convert to microseconds. 188 // Convert to microseconds.
189 int64_t result = ts.tv_sec; 189 int64_t result = ts.tv_sec;
190 result *= kMicrosecondsPerSecond; 190 result *= kMicrosecondsPerSecond;
191 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); 191 result += (ts.tv_nsec / kNanosecondsPerMicrosecond);
192 return result; 192 return result;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 458
459 void OS::Exit(int code) { 459 void OS::Exit(int code) {
460 exit(code); 460 exit(code);
461 } 461 }
462 462
463 } // namespace dart 463 } // namespace dart
464 464
465 #endif // defined(TARGET_OS_ANDROID) 465 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698