commit | e3c22918074fd620fc08fcd5e13500d77442f7c5 | [log] [tgz] |
---|---|---|
author | Ryan Macnak <rmacnak@google.com> | Tue Apr 05 19:23:43 2022 +0000 |
committer | William Hesse <whesse@google.com> | Mon Apr 18 17:48:30 2022 +0200 |
tree | 3f71a81e418d7798b797d149f0c051ab94cdd239 | |
parent | cc81208ca18f15d20b5285af2e6f7d009284e27f [diff] |
[vm] More efficiently access thread CPU time on Mac. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/47850 Change-Id: I5719c42b4e2aa0d1a1b02c5e274cdb9b93177ca1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240148 Reviewed-by: Ben Konyi <bkonyi@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc index eed635d..05f9ee4 100644 --- a/runtime/vm/os_macos.cc +++ b/runtime/vm/os_macos.cc
@@ -106,6 +106,12 @@ } int64_t OS::GetCurrentThreadCPUMicros() { + if (__builtin_available(macOS 10.12, iOS 10.0, *)) { + // This is more efficient when available. + return clock_gettime_nsec_np(CLOCK_THREAD_CPUTIME_ID) / + kNanosecondsPerMicrosecond; + } + mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; thread_basic_info_data_t info_data; thread_basic_info_t info = &info_data;