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

Save baseline does not work in 0.5 #780

Open
aadrijnberg opened this issue May 7, 2024 · 4 comments
Open

Save baseline does not work in 0.5 #780

aadrijnberg opened this issue May 7, 2024 · 4 comments

Comments

@aadrijnberg
Copy link

aadrijnberg commented May 7, 2024

When following the documentation to save a baseline with a name, it returns an error. See https://github.com/aadrijnberg/criterion-benchmark for the repo that tries to use it, but fails with an error:

$ cargo bench -- --save-baseline initial
Finished `bench` profile [optimized] target(s) in 0.10s
 Running unittests src/lib.rs (target/release/deps/criterion_benchmark-c2076c60856bf728)
error: Unrecognized option: 'save-baseline'
error: bench failed, to rerun pass `--lib`

Did I use the wrong command line parameters to store the baseline under a certain name, or is it not working in v0.5

@d2weber
Copy link

d2weber commented Jun 1, 2024

According to the FAQ, it should work with the explicit --bench my_benchmark argument:

cargo bench --bench my_benchmark -- --verbose

Note that my_benchmark here corresponds to the name of your benchmark in your Cargo.toml file.

Another option is to disable benchmarks for your lib or app crate. For example, for library crates, you could add this to your Cargo.toml file:

[lib]
bench = false

@aadrijnberg
Copy link
Author

It is not that I cannot run the benchmarks, it is just that I cannot use the "save-baseline" feature. And I was wondering if my command line was wrong, or that this feature is not working as documented...

@d2weber
Copy link

d2weber commented Jun 2, 2024

It is not that I cannot run the benchmarks, it is just that I cannot use the "save-baseline" feature. And I was wondering if my command line was wrong, or that this feature is not working as documented...

I think my previous comment answers your question. The linked FAQ regards this specific case:
'cargo bench gives "Unrecognized Option" Errors for Valid Command-line Options'

Side note: If you run cargo bench -- --help the end of the message links to this exact same FAQ.

In your case, try:

cargo bench --bench my_benchmark -- --save-baseline initial

instead of

cargo bench -- --save-baseline initial

@aad4
Copy link

aad4 commented Jun 25, 2024

Hah, thanks! That works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants