criterion.rs: error: Unrecognized option: 'save-baseline'

Hi guys, thanks for this great library!

This seems very simple, so it may be my mistake. I am running the following benchmark from /benches/benchmarks.rs:

fn main(){
    
    // make Criterion listen to command line arguments
    let mut c = Criterion::default().configure_from_args();
    
    c.bench(
        "name",
        Benchmark::new("dosomething", move |b| {
            // set up things            
            b.iter(|| 
            // do thing
            )
        })
        // Limit the measurement time and the sample size
        // to make sure the benchmark finishes in a feasible amount of time.
        .measurement_time(Duration::new(100, 0)).sample_size(20)
    );
}

Running cargo bench works, and faithfully runs the above benchmark.

I want to use the --save-baseline command line argument, however, and provide it way the docs suggest:

cargo bench -- --save-baseline master

This produces the following error:

Finished release [optimized] target(s) in 0.13s
Running target/release/deps/abclib-60df177b6b7c338b
error: Unrecognized option: 'save-baseline'
error: bench failed

Initiating the benchmark using the criterion_main!(*) macros instead does not change this.

What is going wrong?

I am running all this on stable. Versions:

cargo 1.28.0 (96a2c7d16 2018-07-13)
stable-x86_64-apple-darwin
rustc 1.28.0 (9634041f0 2018-07-30)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I think that should work, yes. I would go with cargo bench --bench benchmarks -- --save-baseline foo instead, as it’s simpler. It is possible to disable benchmarks in the test exe in your Cargo.toml as well, that would also solve this:

[lib]
bench = false