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

Add a "cargo bench --debug" option #6445

Closed
asomers opened this issue Dec 15, 2018 · 5 comments
Closed

Add a "cargo bench --debug" option #6445

asomers opened this issue Dec 15, 2018 · 5 comments
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches)

Comments

@asomers
Copy link

asomers commented Dec 15, 2018

A mere cargo test neither compiles nor runs the benchmarks. In order to keep them from bitrotting, they must be built and run in CI. But release builds take much more time and RAM than debug builds. In a CI situation, the benchmark results aren't important; only the fact that they can run without errors. So it would be very helpful if there were a cargo bench --debug option

The closest that can be done right now is to do cargo build --benches && target/debug/<my_benchmark>-*. That usage is problematic because

  1. The CI script must be updated everytime a new benchmark program is added, and
  2. That invocation will run old, stale binaries, too.

Instead, it would be great if cargo had a single cargo bench --debug command that would build the benchmarks in debug mode and then run them.

asomers added a commit to asomers/cargo that referenced this issue Dec 15, 2018
It builds the benchmarks in debug mode and then runs them.  It's useful
in a CI context where it's important that the benches aren't broken, but
it's not important how fast they run.

Fixes rust-lang#6445
@droundy
Copy link

droundy commented Dec 6, 2019

Any chance there is a workaround on this yet? I've got a bug that shows up only in my benchmark, and it'd be far easier to find with debug symbols enabled.

@sfackler
Copy link
Member

sfackler commented Dec 6, 2019

You can turn on debug symbols when building benchmarks.

@asomers
Copy link
Author

asomers commented Dec 6, 2019

Try cargo +nightly build --benches.

@ehuss ehuss added the A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) label Apr 6, 2020
@ehuss
Copy link
Contributor

ehuss commented Mar 10, 2021

You can now run cargo test --bench '*' to build and run all of the benchmarks in the benches/ directory, and the libtest test runner will run one iteration to verify that it works.

@asomers
Copy link
Author

asomers commented Jul 28, 2021

@ehuss that's a perfect solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants