Skip to content

Commit e3c2291

Browse files
rmacnak-googlewhesse
authored andcommitted
[vm] More efficiently access thread CPU time on Mac.
TEST=ci Bug: #47850 Change-Id: I5719c42b4e2aa0d1a1b02c5e274cdb9b93177ca1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240148 Reviewed-by: Ben Konyi <[email protected]> Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent cc81208 commit e3c2291

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

runtime/vm/os_macos.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ int64_t OS::GetCurrentMonotonicMicros() {
106106
}
107107

108108
int64_t OS::GetCurrentThreadCPUMicros() {
109+
if (__builtin_available(macOS 10.12, iOS 10.0, *)) {
110+
// This is more efficient when available.
111+
return clock_gettime_nsec_np(CLOCK_THREAD_CPUTIME_ID) /
112+
kNanosecondsPerMicrosecond;
113+
}
114+
109115
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
110116
thread_basic_info_data_t info_data;
111117
thread_basic_info_t info = &info_data;

0 commit comments

Comments
 (0)