-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize and fix time::precise_time_ns() on macos
Use sync::one::Once to fetch the mach_timebase_info only once when running precise_time_ns(). This helps because mach_timebase_info() is surprisingly inefficient. Also fix the order of operations when applying the timebase to the mach absolute time value. This improves the time on my machine from ``` test tests::bench_precise_time_ns ... bench: 157 ns/iter (+/- 4) ``` to ``` test tests::bench_precise_time_ns ... bench: 38 ns/iter (+/- 3) ``` and it will get even faster once #14174 lands.
- Loading branch information
Showing
2 changed files
with
20 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8ef3e22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from alexcrichton
at lilyball@8ef3e22
8ef3e22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging kballard/rust/macos_precise_time_ns = 8ef3e22 into auto
8ef3e22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kballard/rust/macos_precise_time_ns = 8ef3e22 merged ok, testing candidate = 2216ece
8ef3e22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5815
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5813
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4908
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4917
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5912
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/5001
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/5009
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5915
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/5000
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/5006
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/5068
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2801
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5908
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/5004
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/5019
8ef3e22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 2216ece