Skip to content
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

Tracking issue for #[bench] and benchmarking support #29553

Open
alexcrichton opened this Issue Nov 4, 2015 · 12 comments

Comments

Projects
None yet
@alexcrichton
Copy link
Member

alexcrichton commented Nov 4, 2015

This is a tracking issue for the #[bench] attribute and its stability in the compiler. Currently it is not possible to use this from stable Rust as it requires extern crate test which is itself not stable.

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Nov 4, 2015

Nominating for discussion in 1.6, and cc https://internals.rust-lang.org/t/bench-status/2122/10, a thread about this.

I've currently extracted libtest and I would personally like to deprecate #[bench] with a little bit of extra support from perhaps Cargo or the compiler. We'd basically be saying "let's have benchmark support develop externally first" before moving it back in to the compiler.

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Nov 4, 2015

I like bench being as easy to use as it currently is, but would like more functionality.

IMO it would be nice to be able to provide custom providers for --test bineries so you could compile rustc … --test and run binary --bench, binary --quickcheck, binary --criterion etc for whatever testing and benching libraries you’re using.

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Nov 4, 2015

Yeah my feeling here is that I wouldn't want to stabilize anything in the compiler itself unless it looks like a generic "custom test framework" infrastructure, but that's unfortunately a big undertaking that may take awhile. As a result my personal preference is to deprecate the support in the meantime for technically-the-same-if-not-quite-as-easy-to-use support on crates.io

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Nov 5, 2015

The libs team decided to punt on this for 1.6

@briansmith

This comment has been minimized.

Copy link

briansmith commented Feb 1, 2016

This looks like it might be a good replacement for the current #[bench] mechanism: https://github.com/japaric/criterion.rs.

I agree with Alex that deprecation is the best resolution.

zackmdavis added a commit to zackmdavis/Mezzanine that referenced this issue Feb 7, 2016

verdict from the bench: taking stock is free, updating is ruinous
The word upstream is that the unstable builtin benchmark tests are
likely to be deprecated (rust-lang/rust#29553), but I didn't feel like
learning Criterion just for this.

test
inference::triangle::tests::concerning_the_expense_of_computing_entropy
... bench:           0 ns/iter (+/- 0)
test inference::triangle::tests::concerning_the_expense_of_updating
... bench:   1,485,967 ns/iter (+/- 81,055)

I'm not sure how to interpret the zero for computing the entropy; I
assume some sort of clever LLVM optimization has sloughed off the work
to compile time.

But yeah, that 1.5 million nanoseconds to do an update is way too explosive
for a hotspot like `value_of_information`. We're going to need some new
techniques.
@Aatch

This comment has been minimized.

Copy link
Contributor

Aatch commented Apr 12, 2016

This just came up on IRC and should be a consideration for anything we do here. Allowing for "unbenchmarked" parts of an iteration. The specific case this came up for was benchmarking an in-place sorting algorithm. Since performance is going to be different for sorted vs. unsorted lists, you need to clone the list each iteration which can throw off the results.

stewart added a commit to stewart/cargo that referenced this issue Dec 29, 2016

Add "Benchmarks" section to Guide
The `#[bench]` attribute is [currently unstable][1], and is only usable
on nightly Rust.

However, being able to benchmark code with `cargo bench` is very useful
functionality when writing performance-focused code, and something that
the Cargo documentation currently glosses over.

Some useful information on how to get benchmark tests up and running,
with necessary caveats about stability, would likely be very helpful to
new users.

[1]: rust-lang/rust#29553
@fschutt

This comment has been minimized.

Copy link
Contributor

fschutt commented Sep 15, 2017

I'm sorry, but this is still required in nightly 1.20. If I write:

#[bench]
fn bench_blur_image(b: &mut Bencher) {}

Rust complains that it can't find Bencher. You have to use #![feature(test)] and extern crate test still. Why is this not stabilized or that Bencher could be found automatically? Just asking.

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Sep 15, 2017

@fschutt That is correct, benchmarking with #[bench] is unstable on only available in Nightly at the moment. This issue is about tracking its stabilization.

@alkis

This comment has been minimized.

Copy link
Contributor

alkis commented Oct 23, 2017

What's the current status of this given the recent discussion here? Is there another ongoing discussion somewhere else?

@Manishearth

This comment has been minimized.

Copy link
Member

Manishearth commented Jan 11, 2018

@tomaka

This comment has been minimized.

Copy link
Contributor

tomaka commented Oct 19, 2018

Latest development seems to be rust-lang/rfcs#2318

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Mar 25, 2019

Triage: no major movement recently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.