How can I only include a package used for benchmarking when I run cargo bench?
The documentation for targets suggests that this is possible but I can't get it to work.
https://doc.rust-lang.org/cargo/reference/cargo-targets.html
How can I only include a package used for benchmarking when I run cargo bench?
The documentation for targets suggests that this is possible but I can't get it to work.
https://doc.rust-lang.org/cargo/reference/cargo-targets.html
Benchmark dependencies don't get their own section in cargo.toml. You need to put them in the [dev-dependencies] along with test dependencies.
As pointed out by @Dogbert in the comments, there is a related issue: https://github.com/rust-lang/cargo/issues/1596
There is also this useful suggestion to move the benchmarks/quickcheck into a separate repository and use the public interface.
@bluss bluss commented on 2 May 2020 For such cases like benchmarks, for now I'd recommend using an additional non-published crate that you keep in the same repository, that depends on your library and contains the benchmarks. It will need to use the public APIs, of course, but that's ok in most cases. As an example of this, ndarray has a subdirectory for blas-tests that runs tests that depend on BLAS.