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

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

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int64_t TimerUtils::GetCurrentTimeMicros() { 91 int64_t TimerUtils::GetCurrentTimeMicros() {
92 struct timeval tv; 92 struct timeval tv;
93 if (gettimeofday(&tv, NULL) < 0) { 93 if (gettimeofday(&tv, NULL) < 0) {
94 UNREACHABLE(); 94 UNREACHABLE();
95 return 0; 95 return 0;
96 } 96 }
97 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 97 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
98 } 98 }
99 99
100 void TimerUtils::Sleep(int64_t millis) { 100 void TimerUtils::Sleep(int64_t millis) {
101 usleep(millis * 1000); 101 // We must loop here because SIGPROF will interrupt usleep.
102 int64_t micros = millis * 1000;
103 int64_t start = GetCurrentTimeMicros();
104 while (micros > 0) {
105 usleep(micros);
106 int64_t now = GetCurrentTimeMicros();
107 int64_t delta = now - start;
siva 2013/10/28 05:19:21 Ditto.
Cutch 2013/11/04 20:36:05 Done.
108 start = now;
109 micros -= delta;
110 }
102 } 111 }
103 112
104 } // namespace bin 113 } // namespace bin
105 } // namespace dart 114 } // namespace dart
106 115
107 #endif // defined(TARGET_OS_MACOS) 116 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698