[vm] Don't collect thread CPU time for timeline events on iOS.

This clock appears unreliable for durations shorter than ~10ms, which I suspect is the scheduling quantum.

Also remove unnecessary port allocation on macOS.

Bug: https://github.com/flutter/flutter/issues/13111
Change-Id: I9a61fdc076c0766c4519519b4ad6426f2aa556ae
Reviewed-on: https://dart-review.googlesource.com/22282
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2017-11-21 17:13:39 +00:00 committed by commit-bot@chromium.org
parent 54143ef90c
commit 09f63eef5a

View file

@ -106,16 +106,17 @@ int64_t OS::GetCurrentMonotonicMicros() {
}
int64_t OS::GetCurrentThreadCPUMicros() {
#if HOST_OS_IOS
// Thread CPU time appears unreliable on iOS, sometimes incorrectly reporting
// no time elapsed.
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;
}
mach_port_t thread_port = pthread_mach_thread_np(pthread_self());
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);
@ -123,6 +124,7 @@ int64_t OS::GetCurrentThreadCPUMicros() {
thread_cpu_micros += info->user_time.microseconds;
thread_cpu_micros += info->system_time.microseconds;
return thread_cpu_micros;
#endif
}
intptr_t OS::ActivationFrameAlignment() {