about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2014-05-14 17:54:36 -0700
committerKevin Ballard <kevin@sb.org>2014-05-16 14:02:14 -0700
commit8ef3e227198f6ff674b1626d0862c4112358c1a1 (patch)
tree52938169b18421a54344649686e5b33a7f4e320e /src/rustllvm/RustWrapper.cpp
parent25c54226c3e7dd6f59cf2e92238a4d79d8b0128d (diff)
downloadrust-8ef3e227198f6ff674b1626d0862c4112358c1a1.tar.gz
rust-8ef3e227198f6ff674b1626d0862c4112358c1a1.zip
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.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions