Skip to content

Commit

Permalink
test(benches): support benches with optional dev dependency without MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungOnion committed Jun 6, 2024
1 parent c661687 commit c234830
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,31 @@ homepage = "https://github.com/statrs-dev/statrs"
repository = "https://github.com/statrs-dev/statrs"
edition = "2018"
rust-version = "1.61"
include = ["src/", "benches/", "README.md", "CHANGELOG.md", "LICENSE.md", ]
include = ["src/", "README.md", "CHANGELOG.md", "LICENSE.md", ]

[lib]
name = "statrs"
path = "src/lib.rs"

[features]
benches = [
"dep:criterion"
# this enables the `order_statistics` benchmark
# requiring `criterion` crate (higher rust-version as of commit c661687)
]

[dependencies]
rand = "0.8"
nalgebra = { version = "0.32", features = ["rand"] }
approx = "0.5.0"
num-traits = "0.2.14"

# effectively an optional dev-dependency for benchmarking with criterion
criterion = { version = "0.3.3", default-features = false, optional = true }

[dev-dependencies]
criterion = "0.3.3"

[[bench]]
name = "order_statistics"
harness = false
required-features = [ "benches" ]
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ statrs = "*" # replace * by the latest version of the crate.

For examples, view [the docs](https://docs.rs/statrs/*/statrs/).

## Features
This crate has 1 feature. It is not for the lib provided by `statrs`.

- `benches`: enables benchmarking; simulates optional dev-dependency on `criterion` (unsupported, see [`rust-lang/cargo#1596`](https://github.com/rust-lang/cargo/issues/1596)). As of commit c661687, requires higher MSRV than this package.

## Contributing

Thanks for your help to improve the project!
Expand Down Expand Up @@ -102,4 +107,6 @@ Please allow at least one week before pinging issues/pr's.


## MSRV Policy
Not all of our dependencies have an MSRV policy, but our CI will check that our MSRV !(https://img.shields.io/crates/msrv/statrs) is upheld.
Not all of our dependencies have an MSRV policy, but our CI will check that our MSRV ![statrs MSRV badge](https://img.shields.io/crates/msrv/statrs) is upheld with depends via a `Cargo.lock.msrv` file (lockfile not distributed with `crates.io` package)
The provided value for `rust-version` specifies what the `statrs` lib, libtests, and doctests require.

1 change: 1 addition & 0 deletions benches/order_statistics.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "benches")]
extern crate rand;
extern crate statrs;
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
Expand Down

0 comments on commit c234830

Please sign in to comment.