mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[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:
parent
54143ef90c
commit
09f63eef5a
1 changed files with 7 additions and 5 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue