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

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

Issue 1960483002: Include thread CPU time in Timeline (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 9
10 #include <sys/errno.h> // NOLINT 10 #include <sys/errno.h> // NOLINT
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { 188 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) {
189 return reinterpret_cast<ThreadId>(id); 189 return reinterpret_cast<ThreadId>(id);
190 } 190 }
191 191
192 192
193 bool OSThread::Compare(ThreadId a, ThreadId b) { 193 bool OSThread::Compare(ThreadId a, ThreadId b) {
194 return pthread_equal(a, b) != 0; 194 return pthread_equal(a, b) != 0;
195 } 195 }
196 196
197 197
198 void OSThread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
199 ASSERT(thread_id == GetCurrentThreadId());
200 ASSERT(cpu_usage != NULL);
201 // TODO(johnmccutchan): Enable this after fixing issue with macos directory
202 // watcher.
203 const bool get_cpu_usage = false;
204 if (get_cpu_usage) {
205 mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
206 thread_basic_info_data_t info_data;
207 thread_basic_info_t info = &info_data;
208 mach_port_t thread_port = mach_thread_self();
209 kern_return_t r = thread_info(thread_port, THREAD_BASIC_INFO,
210 (thread_info_t)info, &count);
211 mach_port_deallocate(mach_task_self(), thread_port);
212 if (r == KERN_SUCCESS) {
213 *cpu_usage = (info->user_time.seconds * kMicrosecondsPerSecond) +
214 info->user_time.microseconds;
215 return;
216 }
217 }
218 *cpu_usage = 0;
219 }
220
221
222 Mutex::Mutex() { 198 Mutex::Mutex() {
223 pthread_mutexattr_t attr; 199 pthread_mutexattr_t attr;
224 int result = pthread_mutexattr_init(&attr); 200 int result = pthread_mutexattr_init(&attr);
225 VALIDATE_PTHREAD_RESULT(result); 201 VALIDATE_PTHREAD_RESULT(result);
226 202
227 #if defined(DEBUG) 203 #if defined(DEBUG)
228 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 204 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
229 VALIDATE_PTHREAD_RESULT(result); 205 VALIDATE_PTHREAD_RESULT(result);
230 #endif // defined(DEBUG) 206 #endif // defined(DEBUG)
231 207
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 void Monitor::NotifyAll() { 410 void Monitor::NotifyAll() {
435 // When running with assertions enabled we track the owner. 411 // When running with assertions enabled we track the owner.
436 ASSERT(IsOwnedByCurrentThread()); 412 ASSERT(IsOwnedByCurrentThread());
437 int result = pthread_cond_broadcast(data_.cond()); 413 int result = pthread_cond_broadcast(data_.cond());
438 VALIDATE_PTHREAD_RESULT(result); 414 VALIDATE_PTHREAD_RESULT(result);
439 } 415 }
440 416
441 } // namespace dart 417 } // namespace dart
442 418
443 #endif // defined(TARGET_OS_MACOS) 419 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698