Repository navigation
Use clock_gettime on all MacOS after 10.11 - #2341
nicholasjng wants to merge 3 commits into
Conversation
| (static_cast<double>(ts.tv_nsec) * 1e-9); | ||
| } | ||
| DiagnoseAndExit("clock_gettime(CLOCK_MONOTONIC, ...) failed"); | ||
| #elif defined(CLOCK_PROCESS_CPUTIME_ID) && !defined(BENCHMARK_OS_MACOSX) |
There was a problem hiding this comment.
we should just remove this section then i think?
There was a problem hiding this comment.
I think if C++17 is the floor now, which requires macOS 10.14+, it's reasonable to assume clock_gettime to always be available, but I didn't want to break backwards compatibility without confirmation.
There was a problem hiding this comment.
right, but your new check below will use thread_id if the version is older, and if not then it'll fall through to the bottom CLOCK_PROCESS_CPUTIME_ID check (line 216) and use clock_gettime. so i think this section is redundant?
There was a problem hiding this comment.
this block is for ProcessCPUUsage(), line 216 is for ThreadCPUUsage(). could you recheck?
I also think this could be simplified, but we need to untangle the two functions, and I'd like your opinion on whether to drop support for macOS without clock_gettime.
There was a problem hiding this comment.
10 years is plenty of time. i think we can drop support for the older versions.
There was a problem hiding this comment.
nice, i pushed two more commits with the necessary cleanups.
|
re: the clang-format failure: the struct declarations were autofixed on |
e18e50b to
830f35f
Compare
`clock_gettime` is available on macOS since 10.12 (September 2016), and noticeably faster than mach's `thread_info`, so use it whenever available. Assisted-By: Codex
830f35f to
6ed8b4e
Compare
e7332a3 to
6ed8b4e
Compare
Since we assume that we can access `clock_gettime()` on all supported macOS versions, we can remove the mach thread-info route entirely.
clock_gettimeis available on macOS since 10.12 (September 2016), and noticeably faster than mach'sthread_info, so use it whenever available.Assisted-By: Codex
From experimentation with scoped pauses in
mew. This cuts around 500ns off the total cost of a pause in Python code.EDIT:
clock_gettimeis available here because of<ctime>, which includes<time.h>on Apple's libc++.