156 Commits

Author SHA1 Message Date
Vinzent Steinberg
4f8257a986
Rename Rng::gen to Rng::random (#1438) 2024-04-29 19:41:10 +01:00
Diggory Hardy
e55b1f6ee5 Merge rand_distr/benches into benches 2024-04-27 08:59:58 +01:00
Diggory Hardy
24b84a09a1 Move Criterion benches to benches/src 2024-04-27 08:46:09 +01:00
Diggory Hardy
3c0661b804 Rename rand_benches -> benches 2024-04-27 08:46:09 +01:00
Vinzent Steinberg
6f917e1f16 Move rand benches to their own crate 2024-04-26 14:21:28 +02:00
Michael Dyer
bca078e929
Optimize imports (#1430) 2024-04-05 16:04:30 +01:00
Diggory Hardy
4cbbb340ad
Remove automatic (delayed) reseed-on-fork (#1379)
* benches/generators.rs: standardize thread_rng benchmarks
* Remove cfgs from examples
* Remove ReadRng
* Add ThreadRng::reseed and doc to use
* Remove fork protection from ReseedingRng; remove libc dep
* Enable ReseedingRng without std
* Move ReseedingRng up; remove module rand::rngs::adapter
2024-03-18 17:41:15 +00:00
Diggory Hardy
1db3aa416c
Replace SeedableRng impl for SmallRng with inherent fns (#1368)
* Simplify redundant doc-link

* Remove impl of SeedableRng for SmallRng

* Fix SeedableRng::Seed type for StdRng

* SmallRng: do not expect thread_rng

* Make SmallRng::from_thread_rng infallible

* Fix benchmarks (SmallRng does not have from_entropy)
2024-01-05 10:58:22 +00:00
Vinzent Steinberg
c427cff1d5 Fix clippy warnings 2023-12-14 08:50:57 +01:00
Vinzent Steinberg
026292d316
Merge branch 'master' into uniform-float 2023-05-01 16:39:12 +02:00
Diggory Hardy
22d0756b68
Uniform sampling: use Canon's method, Lemire's method (#1287)
Also:

* Add uniform distribution benchmarks
* Add "unbiased" feature flag
* Fix feature simd_support
* Uniform: impl PartialEq, Eq where possible
* CI: benches now require small_rng; build-test unbiased
2023-03-24 12:29:15 +00:00
Diggory Hardy
8d98d4531d Bench uniform_float: better grouping of plots
Also avoid using internal API of Uniform distribution.
2023-03-18 09:54:12 +00:00
Diggory Hardy
95b366ff53 Add uniform_float benchmark
Note: sample_single and sample_single_inclusive use
different code paths for sampling.
2023-02-21 12:58:18 +00:00
Vinzent Steinberg
7d73990096
Make Uniform constructors return a result (#1229)
* Forbid unsafe code in crates without unsafe code

This helps tools like `cargo geiger`.

* Make `Uniform` constructors return a result

- This is a breaking change.
- The new error type had to be made public, otherwise `Uniform` could
  not be extended for user-defined types by implementing
  `UniformSampler`.
- `rand_distr` was updated accordingly.
- Also forbid unsafe code for crates where none is used.

Fixes #1195, #1211.

* Address review feedback
* Make `sample_single` return a `Result`
* Fix benchmarks
* Small fixes
* Update src/distributions/uniform.rs
2023-02-06 10:55:22 +00:00
Mark Wainwright
4bde8a0adb
Performance improvements for shuffle and partial_shuffle (#1272)
* Made shuffle and partial_shuffle faster
* Use criterion benchmarks for shuffle
* Added a note about RNG word size
* Tidied comments
* Added a debug_assert
* Added a comment re possible further optimization
* Added and updated copyright notices
* Revert cfg mistake
* Reverted change to mod.rs
* Removed ChaCha20 benches from shuffle
* moved debug_assert out of a const fn
2023-01-08 16:14:26 +00:00
Mark Wainwright
1e96eb4593
Added new versions of choose and choose_stable (#1268)
* Added new versions of choose and choose_stable

* Removed coin_flipper tests which were unnecessary and not building on ci

* Performance optimizations in coin_flipper

* Clippy fixes and more documentation

* Added a correctness fix for coin_flipper

* Update benches/seq.rs

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>

* Update benches/seq.rs

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>

* Removed old version of choose and choose stable and updated value stability tests

* Moved sequence choose benchmarks to their own file

* Reworked coin_flipper

* Use criterion for seq_choose benches

* Removed an old comment

* Change how c is estimated in coin_flipper

* Revert "Use criterion for seq_choose benches"

This reverts commit 23395391370ab95694558be90686eb16494e590a.

* Added seq_choose benches for smaller numbers

* Removed some unneeded lines from seq_choose

* Improvements in coin_flipper.rs

* Small refactor of coin_flipper

* Tidied comments in coin_flipper

* Use criterion for seq_choose benchmarks

* Made choose not generate a random number if len=1

* small change to IteratorRandom::choose

* Made it easier to change seq_choose benchmarks RNG

* Added Pcg64 benchmarks for seq_choose

* Added TODO to coin_flipper

* Changed criterion settings in seq_choose

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
2023-01-05 10:49:33 +00:00
Adam Reichold
f44ea42089 Extend generator benchmarks to include the newly added Pcg64Dxsm variant. 2021-12-06 13:41:05 +01:00
Brandon H. Gomes
1544c728cd
fix no_std/alloc/std compatibility issues
- using min_const_gen on no_std fails to compile because of a bad import
- sample_efraimidis_spirakis only requires alloc but it was marked with
  a std requirement
2021-09-04 18:33:39 -04:00
Vinzent Steinberg
067238f057
Remove rand_hc (#1156)
* Remove `rand_hc`

We no longer need it for `rand`, so it can be moved to the `rngs`
repository.
2021-08-05 14:59:07 +02:00
Vinzent Steinberg
1b8eaf23ea rand: Fix clippy warnings 2021-05-08 21:37:15 -03:00
Zachary Neely
9b4df3bb0b Add choose_multiple_weighted, tests, and benchmarks 2020-08-27 18:21:07 +02:00
Vinzent Steinberg
bbb0dff53c Fix benchmarks 2020-08-05 13:25:25 +02:00
Vinzent Steinberg
98b915feed Change gen_range to accept Range types
This adds support for `Rng::range(a..b)` and `Rng::range(a..=b)`,
replacing `Rng::range(a, b)`. `a` and `b` must now implement
`PartialEq`.

This is a breaking change. In most cases, replacing
`Rng::gen_range(a, b)` with `Rng::gen_range(a..b)` should be enough,
however type annotations may be necessary, and `a` and `b` can no longer
be references or SIMD types.

SIMD types are still supported by `UniformSampler::sample_single`.

Some clippy warnings were fixed as well.
2020-08-01 16:09:50 +02:00
Jonathan Giddy
c337164bbb Add a benchmark for UniformInt sample_single 2020-07-18 08:14:11 +01:00
Jonathan Giddy
1d54f1190f Move standard and uniform benchmarks to top-level crate 2020-07-08 07:45:01 +01:00
Diggory Hardy
571c9af9a6 Misc bench: add gen_1kb_u16_* 2020-02-28 15:34:08 +00:00
Diggory Hardy
92e07018e0 rustfmt: expression spacing (on the line) 2020-01-02 15:46:14 +00:00
Diggory Hardy
0f9500b725 rustfmt: function parameters 2020-01-02 15:46:14 +00:00
Diggory Hardy
1b3bcce9be rustfmt: closures 2020-01-02 15:46:14 +00:00
Diggory Hardy
363571540f rustfmt: method chaining 2020-01-02 15:46:14 +00:00
Diggory Hardy
4f1f0fce67 rustfmt: struct literals, if/for blocks 2020-01-02 15:46:14 +00:00
Diggory Hardy
477b47058f rustfmt: spacing, new-lines, trailing commas/semicolon 2020-01-02 15:46:14 +00:00
Diggory Hardy
ccb64dc0a0 rustfmt: attributes 2020-01-02 15:46:14 +00:00
Diggory Hardy
88aa915c66 rustfmt: use, mod statements and initial attributes 2020-01-02 15:46:14 +00:00
Diggory Hardy
2fc64ed429 Remove old RNG crates from benchmarks
Note: the init benches now use a different master RNG;
this appears to have little affect on results.
2019-09-20 16:47:46 +01:00
Vinzent Steinberg
ee6f33453e WeightedIndex: Clean up benchmark 2019-08-15 18:24:00 +02:00
Vinzent Steinberg
7351358e5a Benchmark creation vs. modification of WeightedIndex 2019-08-14 15:57:14 +02:00
Diggory Hardy
2dca83d861 Add inlining for StepRng 2019-06-27 10:01:12 +01:00
Vinzent Steinberg
8521f85b31 Fix benchmarks 2019-06-21 17:58:05 +02:00
Vinzent Steinberg
75d639b78d rand: Use Rust 2018 2019-06-12 17:02:36 +02:00
Diggory Hardy
18d55845ea rand_pcg: add Pcg64 RNG
Note: benchmarks now show different results to mentioned
for fill_bytes impl, possibly because of #[inline] changes
2019-06-11 13:29:21 +01:00
Diggory Hardy
01b1bf8958 Move distributions benchmark to rand_distr
This avoids a circular dependency between rand and rand_distr
2019-06-11 10:42:41 +01:00
Diggory Hardy
076fd1208e Benchmarks: enable usage without feature flags 2019-06-11 10:32:42 +01:00
Diggory Hardy
33bd4040f6 Replace StdRng algorithm with ChaCha20 and adjust reseeding threshold 2019-06-03 15:39:21 +01:00
Diggory Hardy
25896a7533 Add benchmarks for uniform usize samples
The usize64 bench is noticably slower than the others,
perhaps due to use of rejection sampling.
2019-06-03 14:25:37 +01:00
Vinzent Steinberg
c6bce2cec3 Make Bernoulli::new return a Result
Fixes #799.
2019-05-22 17:36:23 +02:00
Vinzent Steinberg
ec2f006d3c Fix benchmarks 2019-05-16 13:55:51 +02:00
Diggory Hardy
29da6f9061 Add benchmarks for new chacha variants 2019-04-30 21:14:42 +01:00
Diggory Hardy
1f7af60419
Merge pull request #782 from dhardy/distr
Add PERT distribution
2019-04-23 15:14:01 +01:00
Diggory Hardy
f8a7b42dd4 rand_distr::Triangular: tweaks, bench and tests 2019-04-22 17:49:31 +01:00