-
Notifications
You must be signed in to change notification settings - Fork 13.3k
extra::test: define an opaque function to assist with accurate benchmarking. #12105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'll file a bug replacing #8261 about fixing the various overly-optimised benchmarks in the source tree when this lands. |
Is there any way you could use |
Probably, but I don't think that's particularly better than this solution. (It might maybe work better in the face of LTO; I'll test.) |
I've added two new commits; the second of which is an example of how to fix broken benchmarks. |
It seems a little unfortunate to require that most benchmarks use |
I think @alexcrichton's suggestion is the right way to go. |
benchmarking. This allows a result to be marked as "used" by passing it to a function LLVM cannot see inside. By making `iter` generic and using this `black_box` on the result benchmarks can get this behaviour simply by returning their computation.
Before: test test::bench_nonpod_nonarena ... bench: 62 ns/iter (+/- 6) test test::bench_pod_nonarena ... bench: 0 ns/iter (+/- 0) After: test test::bench_nonpod_nonarena ... bench: 158 ns/iter (+/- 11) test test::bench_pod_nonarena ... bench: 48 ns/iter (+/- 2) The other tests show no change, but are adjusted to use the generic return value of `.iter` anyway so that this doesn't change in future.
Done. |
This allows a result to be marked as "used" by passing it to a function LLVM cannot see inside (unless LTO is enabled). Closes #8261.
… r=llogiq Extend `useless_asref` lint on `map(clone)` If you have code like: ```rust Some(String::new()).as_ref().map(Clone::clone) ``` the `as_ref` call is unneeded. Interestingly enough, this lint and `map_clone` are starting to share a same "space" where both lints warn about different things for the same code. Not sure what's the policy about such cases though... r? `@llogiq` changelog: Extend `useless_asref` lint on `map(clone)`
This allows a result to be marked as "used" by passing it to a function
LLVM cannot see inside (unless LTO is enabled).
Closes #8261.