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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_macos.cc
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index d2d5576261c19b795f31fcdf7c1c8bb9cf6b85e0..31bb3e86917d944d10b6d5530bb02d665486e344 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -139,6 +139,32 @@ int64_t OS::GetCurrentMonotonicMicros() {
}
+int64_t OS::GetCurrentThreadCPUMicros() {
+#if TARGET_OS_IOS
+ // 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.
+ return -1
+#else
+ mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
+ thread_basic_info_data_t info_data;
+ thread_basic_info_t info = &info_data;
+ mach_port_t thread_port = mach_thread_self();
+ if (thread_port == MACH_PORT_NULL) {
+ return -1;
+ }
+ kern_return_t r = thread_info(thread_port, THREAD_BASIC_INFO,
+ (thread_info_t)info, &count);
+ mach_port_deallocate(mach_task_self(), thread_port);
+ ASSERT(r == KERN_SUCCESS);
+ int64_t thread_cpu_micros =
+ (info->system_time.seconds + info->user_time.seconds);
+ thread_cpu_micros *= kMicrosecondsPerSecond;
+ thread_cpu_micros += info->user_time.microseconds;
+ thread_cpu_micros += info->system_time.microseconds
+ return thread_cpu_micros;
+#endif // TARGET_OS_IOS
+}
+
+
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
« 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