diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1c5b39b618..495571d2620 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,8 +79,7 @@ jobs: run: | cargo test --target ${{ matrix.target }} --features=nightly cargo test --target ${{ matrix.target }} --all-features - cargo test --target ${{ matrix.target }} --benches --features=small_rng,nightly - cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --benches + cargo test --target ${{ matrix.target }} --manifest-path benches/Cargo.toml --benches cargo test --target ${{ matrix.target }} --lib --tests --no-default-features - name: Test rand run: | @@ -104,7 +103,7 @@ jobs: - name: Test rand_pcg run: cargo test --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde1 - name: Test rand_chacha - run: cargo test --target ${{ matrix.target }} --manifest-path rand_chacha/Cargo.toml + run: cargo test --target ${{ matrix.target }} --manifest-path rand_chacha/Cargo.toml --features=serde1 test-cross: runs-on: ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9019ae4b8b5..ba7fd2d7a0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update. ## [Unreleased] - Add `rand::distributions::WeightedIndex::{weight, weights, total_weight}` (#1420) - Bump the MSRV to 1.61.0 +- Move all benchmarks to new `benches` crate (#1439) ## [0.9.0-alpha.1] - 2024-03-18 - Add the `Slice::num_choices` method to the Slice distribution (#1402) diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv index 0a197d12e04..bf15ecb24d7 100644 --- a/Cargo.lock.msrv +++ b/Cargo.lock.msrv @@ -33,15 +33,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "autocfg" @@ -51,9 +46,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "average" -version = "0.14.1" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d804c74bb2d66e9b7047658d21af0f1c937d7d2466410cbf1aed3b0c04048d4" +checksum = "3a237a6822e1c3c98e700b6db5b293eb341b7524dcb8d227941245702b7431dc" dependencies = [ "easy-cast", "float-ord", @@ -66,6 +61,18 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "benches" +version = "0.1.0" +dependencies = [ + "criterion", + "criterion-cycles-per-byte", + "rand", + "rand_chacha", + "rand_distr", + "rand_pcg", +] + [[package]] name = "bincode" version = "1.3.3" @@ -75,12 +82,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bumpalo" version = "3.15.4" @@ -147,25 +148,29 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.25" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ - "bitflags", - "clap_lex", - "indexmap 1.9.3", - "textwrap", + "clap_builder", ] [[package]] -name = "clap_lex" -version = "0.2.4" +name = "clap_builder" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ - "os_str_bytes", + "anstyle", + "clap_lex", ] +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -174,19 +179,19 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "criterion" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ "anes", - "atty", "cast", "ciborium", "clap", "criterion-plot", + "is-terminal", "itertools", - "lazy_static", "num-traits", + "once_cell", "oorandom", "plotters", "rayon", @@ -198,6 +203,15 @@ dependencies = [ "walkdir", ] +[[package]] +name = "criterion-cycles-per-byte" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5281161544b8f2397e14942c2045efa3446470348121a65c37263f8e76c1e2ff" +dependencies = [ + "criterion", +] + [[package]] name = "criterion-plot" version = "0.5.0" @@ -358,15 +372,6 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -430,6 +435,17 @@ dependencies = [ "serde", ] +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + [[package]] name = "itertools" version = "0.10.5" @@ -454,12 +470,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.153" @@ -506,7 +516,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -522,12 +532,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "plotters" version = "0.3.5" @@ -591,7 +595,6 @@ name = "rand" version = "0.9.0-alpha.1" dependencies = [ "bincode", - "criterion", "log", "rand_chacha", "rand_core", @@ -644,9 +647,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -795,12 +798,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" - [[package]] name = "time" version = "0.3.34" @@ -968,6 +965,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.4" diff --git a/Cargo.toml b/Cargo.toml index 6c7ce73f66a..48f8719e292 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,7 @@ unbiased = [] [workspace] members = [ + "benches", "rand_core", "rand_distr", "rand_chacha", @@ -75,25 +76,4 @@ zerocopy = { version = "=0.8.0-alpha.6", default-features = false, features = [" rand_pcg = { path = "rand_pcg", version = "=0.9.0-alpha.1" } # Only to test serde1 bincode = "1.2.1" -rayon = "1.5.3" -criterion = { version = "0.4" } - -[[bench]] -name = "uniform" -path = "benches/uniform.rs" -harness = false - -[[bench]] -name = "seq_choose" -path = "benches/seq_choose.rs" -harness = false - -[[bench]] -name = "shuffle" -path = "benches/shuffle.rs" -harness = false - -[[bench]] -name = "uniform_float" -path = "benches/uniform_float.rs" -harness = false +rayon = "1.7" diff --git a/benches/Cargo.toml b/benches/Cargo.toml new file mode 100644 index 00000000000..b3068c2f758 --- /dev/null +++ b/benches/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "benches" +version = "0.1.0" +edition = "2021" +publish = false + +[dependencies] + +[dev-dependencies] +rand = { path = "..", features = ["small_rng", "nightly"] } +rand_pcg = { path = "../rand_pcg" } +rand_chacha = { path = "../rand_chacha" } +rand_distr = { path = "../rand_distr" } +criterion = "0.5" +criterion-cycles-per-byte = "0.6" + +[[bench]] +name = "distributions" +path = "src/distributions.rs" +harness = false + +[[bench]] +name = "uniform" +path = "src/uniform.rs" +harness = false + +[[bench]] +name = "seq_choose" +path = "src/seq_choose.rs" +harness = false + +[[bench]] +name = "shuffle" +path = "src/shuffle.rs" +harness = false + +[[bench]] +name = "uniform_float" +path = "src/uniform_float.rs" +harness = false diff --git a/benches/distributions.rs b/benches/benches/base_distributions.rs similarity index 100% rename from benches/distributions.rs rename to benches/benches/base_distributions.rs diff --git a/benches/generators.rs b/benches/benches/generators.rs similarity index 100% rename from benches/generators.rs rename to benches/benches/generators.rs diff --git a/benches/misc.rs b/benches/benches/misc.rs similarity index 100% rename from benches/misc.rs rename to benches/benches/misc.rs diff --git a/benches/seq.rs b/benches/benches/seq.rs similarity index 100% rename from benches/seq.rs rename to benches/benches/seq.rs diff --git a/benches/weighted.rs b/benches/benches/weighted.rs similarity index 100% rename from benches/weighted.rs rename to benches/benches/weighted.rs diff --git a/rand_distr/benches/src/distributions.rs b/benches/src/distributions.rs similarity index 100% rename from rand_distr/benches/src/distributions.rs rename to benches/src/distributions.rs diff --git a/benches/seq_choose.rs b/benches/src/seq_choose.rs similarity index 100% rename from benches/seq_choose.rs rename to benches/src/seq_choose.rs diff --git a/benches/shuffle.rs b/benches/src/shuffle.rs similarity index 100% rename from benches/shuffle.rs rename to benches/src/shuffle.rs diff --git a/benches/uniform.rs b/benches/src/uniform.rs similarity index 100% rename from benches/uniform.rs rename to benches/src/uniform.rs diff --git a/benches/uniform_float.rs b/benches/src/uniform_float.rs similarity index 100% rename from benches/uniform_float.rs rename to benches/src/uniform_float.rs diff --git a/rand_distr/benches/Cargo.toml b/rand_distr/benches/Cargo.toml deleted file mode 100644 index e9c41c31540..00000000000 --- a/rand_distr/benches/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "benches" -version = "0.0.0" -authors = ["The Rand Project Developers"] -license = "MIT OR Apache-2.0" -description = "Criterion benchmarks of the rand_distr crate" -edition = "2021" -rust-version = "1.61" -publish = false - -[workspace] - -[dependencies] -criterion = { version = "0.3", features = ["html_reports"] } -criterion-cycles-per-byte = "0.1" -rand = { path = "../../" } -rand_distr = { path = "../" } -rand_pcg = { path = "../../rand_pcg/" } - -[[bench]] -name = "distributions" -path = "src/distributions.rs" -harness = false