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

Side by Side Diff: runtime/bin/utils_linux.cc

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/utils_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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <netdb.h> // NOLINT 9 #include <netdb.h> // NOLINT
10 #include <sys/time.h> // NOLINT 10 #include <sys/time.h> // NOLINT
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 int64_t TimerUtils::GetCurrentTimeMicros() { 89 int64_t TimerUtils::GetCurrentTimeMicros() {
90 struct timeval tv; 90 struct timeval tv;
91 if (gettimeofday(&tv, NULL) < 0) { 91 if (gettimeofday(&tv, NULL) < 0) {
92 UNREACHABLE(); 92 UNREACHABLE();
93 return 0; 93 return 0;
94 } 94 }
95 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 95 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
96 } 96 }
97 97
98 void TimerUtils::Sleep(int64_t millis) { 98 void TimerUtils::Sleep(int64_t millis) {
99 usleep(millis * 1000); 99 // We must loop here because SIGPROF will interrupt usleep.
100 int64_t micros = millis * 1000;
101 int64_t start = GetCurrentTimeMicros();
102 while (micros > 0) {
103 usleep(micros);
104 int64_t now = GetCurrentTimeMicros();
105 int64_t delta = now - start;
106 ASSERT(delta >= 0);
107 start = now;
108 micros -= delta;
109 }
100 } 110 }
101 111
102 } // namespace bin 112 } // namespace bin
103 } // namespace dart 113 } // namespace dart
104 114
105 #endif // defined(TARGET_OS_LINUX) 115 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/utils_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698