Description
I’ll take the liberty of copying a section of @hsivonen’s Rust 2020 blog post:
Non-Nightly Benchmarking
The library support for the
cargo bench
feature has been in the state “basically, the design is problematic, but we haven’t had anyone work through those issues yet” since 2015. It’s a useful feature nonetheless. Like I said a year ago and the year before, it’s time to let go of the possibility of tweaking it for elegance and just let users use it on non-nighly Rust.
Indeed the existing benchmarking support has basically not changed in years, and I’m not aware of anyone planning to work on it. To keep reserving the right to make breaking changes is not useful at this point. Custom test frameworks offer another way forward for when someone does want to work on better benchmarking.
So I’d like to propose a plan:
- Move
test::Bencher
tostd::bench::Bencher
.I have a PR coming soon thatMovetest::Bencher
to a new (unstable)std::bench
module #66290 demonstrates that this is possible. This move avoids the need to stabilize thetest
crate. - Optionally, make some surface-only API tweaks to
Bencher
. For example, the publicbytes
field could become a parameter to some method.- Although not strictly necessary for changes to an unstable type, we can keep the existing
bytes
field anditer
method unchanged as unstable + deprecated for a while.
- Although not strictly necessary for changes to an unstable type, we can keep the existing
- Stabilize the
#[bench]
attribute and just enough ofBencher
to make it usable with#[bench]
. (For example, no stable constructor.)
@rust-lang/libs, @rust-lang/lang, do you feel this needs an RFC?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status