Skip to content

Commit

Permalink
Rework FAQ to explain the Unrecognized Option error better. Fixes #193
Browse files Browse the repository at this point in the history
  • Loading branch information
bheisler committed Aug 25, 2018
1 parent ee719e8 commit 27512db
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions book/src/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ benchmarks that detect performance regressions should not cause the build to
fail, and apparent performance regressions should be verified manually before
rejecting a pull request.

### `cargo bench -- --verbose` Panics

This occurs because the `libtest` benchmark harness implicitly added to your
crate is executing before the Criterion.rs benchmarks, and it panics when
presented with a command-line argument it doesn't expect. There are two ways to
work around this at present:
### `cargo bench` Gives "Unrecognized Option" Errors for Valid Command-line Options

By default, Cargo implicitly adds a `libtest` benchmark harness to your crate when benchmarking, to
handle any `#[bench]` functions, even if you have none. It compiles and runs this executable first,
before any of the other benchmarks. Normally, this is fine - it detects that there are no `libtest`
benchmarks to execute and exits, allowing Cargo to move on to the real benchmarks. Unfortunately,
it checks the command-line arguments first, and panics when it finds one it doesn't understand.
This causes Cargo to stop benchmarking early, and it never executes the Criterion.rs benchmarks.

This will occur when running `cargo bench` with any argument that Criterion.rs supports but `libtest`
does not. For example, `--verbose` and `--save-baseline` will cause this issue, while `--help` will
not. There are two ways to work around this at present:

You could run only your Criterion benchmark, like so:

Expand Down

0 comments on commit 27512db

Please sign in to comment.