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

Side by Side Diff: runtime/vm/os_linux.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_android.cc ('k') | runtime/vm/os_macos.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_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // gettimeofday has microsecond resolution. 389 // gettimeofday has microsecond resolution.
390 struct timeval tv; 390 struct timeval tv;
391 if (gettimeofday(&tv, NULL) < 0) { 391 if (gettimeofday(&tv, NULL) < 0) {
392 UNREACHABLE(); 392 UNREACHABLE();
393 return 0; 393 return 0;
394 } 394 }
395 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 395 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
396 } 396 }
397 397
398 398
399 int64_t OS::GetCurrentTraceMicros() { 399 int64_t OS::GetCurrentMonotonicMicros() {
400 struct timespec ts; 400 struct timespec ts;
401 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { 401 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
402 UNREACHABLE(); 402 UNREACHABLE();
403 return 0; 403 return 0;
404 } 404 }
405 // Convert to microseconds. 405 // Convert to microseconds.
406 int64_t result = ts.tv_sec; 406 int64_t result = ts.tv_sec;
407 result *= kMicrosecondsPerSecond; 407 result *= kMicrosecondsPerSecond;
408 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); 408 result += (ts.tv_nsec / kNanosecondsPerMicrosecond);
409 return result; 409 return result;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 647 }
648 648
649 649
650 void OS::Exit(int code) { 650 void OS::Exit(int code) {
651 exit(code); 651 exit(code);
652 } 652 }
653 653
654 } // namespace dart 654 } // namespace dart
655 655
656 #endif // defined(TARGET_OS_LINUX) 656 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/vm/os_android.cc ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698