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

Side by Side Diff: runtime/vm/os_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
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_thread.h » ('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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 #if TARGET_OS_IOS 132 #if TARGET_OS_IOS
133 ASSERT(GetCurrentMonotonicFrequency() == kMicrosecondsPerSecond); 133 ASSERT(GetCurrentMonotonicFrequency() == kMicrosecondsPerSecond);
134 return GetCurrentMonotonicTicks(); 134 return GetCurrentMonotonicTicks();
135 #else 135 #else
136 ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond); 136 ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond);
137 return GetCurrentMonotonicTicks() / kNanosecondsPerMicrosecond; 137 return GetCurrentMonotonicTicks() / kNanosecondsPerMicrosecond;
138 #endif // TARGET_OS_IOS 138 #endif // TARGET_OS_IOS
139 } 139 }
140 140
141 141
142 int64_t OS::GetCurrentThreadCPUMicros() {
143 #if TARGET_OS_IOS
144 // TODO(johnmccutchan): Implement this. No implementation exists in base.
jamesr 2016/05/09 19:52:22 FYI Chinmay investigated this function for iOS for
Cutch 2016/05/09 20:38:41 Acknowledged.
145 return -1
146 #else
147 mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
148 thread_basic_info_data_t info_data;
149 thread_basic_info_t info = &info_data;
150 mach_port_t thread_port = mach_thread_self();
151 if (thread_port == MACH_PORT_NULL) {
152 return -1;
153 }
154 kern_return_t r = thread_info(thread_port, THREAD_BASIC_INFO,
155 (thread_info_t)info, &count);
156 mach_port_deallocate(mach_task_self(), thread_port);
157 ASSERT(r == KERN_SUCCESS);
158 int64_t thread_cpu_micros =
159 (info->system_time.seconds + info->user_time.seconds);
160 thread_cpu_micros *= kMicrosecondsPerSecond;
161 thread_cpu_micros += info->user_time.microseconds;
162 thread_cpu_micros += info->system_time.microseconds
163 return thread_cpu_micros;
164 #endif // TARGET_OS_IOS
165 }
166
167
142 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { 168 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
143 const int kMinimumAlignment = 16; 169 const int kMinimumAlignment = 16;
144 ASSERT(Utils::IsPowerOfTwo(alignment)); 170 ASSERT(Utils::IsPowerOfTwo(alignment));
145 ASSERT(alignment >= kMinimumAlignment); 171 ASSERT(alignment >= kMinimumAlignment);
146 // Temporary workaround until xcode is upgraded. 172 // Temporary workaround until xcode is upgraded.
147 // Mac guarantees malloc returns a 16 byte aligned memory chunk. 173 // Mac guarantees malloc returns a 16 byte aligned memory chunk.
148 // Currently we only allocate with 16-bye alignment. 174 // Currently we only allocate with 16-bye alignment.
149 ASSERT(alignment == 16); 175 ASSERT(alignment == 16);
150 // TODO(johnmccutchan): Remove hack and switch to posix_memalign. 176 // TODO(johnmccutchan): Remove hack and switch to posix_memalign.
151 return malloc(size); 177 return malloc(size);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 415 }
390 416
391 417
392 void OS::Exit(int code) { 418 void OS::Exit(int code) {
393 exit(code); 419 exit(code);
394 } 420 }
395 421
396 } // namespace dart 422 } // namespace dart
397 423
398 #endif // defined(TARGET_OS_MACOS) 424 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698