Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention that Fill supports floats #1183

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/distributions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ use crate::Rng;
/// * Tuples (up to 12 elements): each element is generated sequentially.
/// * Arrays (up to 32 elements): each element is generated sequentially;
/// see also [`Rng::fill`] which supports arbitrary array length for integer
/// types and tends to be faster for `u32` and smaller types.
/// and float types and tends to be faster for `u32` and smaller types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little ambiguous: where exactly is fill faster and where does it produce different results? This doc was written before fill supported floats (for AsBytesMut trait IIRC).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, this should be verified in benchmarks as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vks we have benches:

$ cargo +nightly bench --bench misc gen_1kb

running 8 tests
test gen_1kb_u16_fill        ... bench:         137 ns/iter (+/- 0) = 7474 MB/s
test gen_1kb_u16_gen_array   ... bench:         445 ns/iter (+/- 2) = 2301 MB/s
test gen_1kb_u16_iter_repeat ... bench:         485 ns/iter (+/- 0) = 2111 MB/s
test gen_1kb_u16_sample_iter ... bench:         660 ns/iter (+/- 2) = 1551 MB/s
test gen_1kb_u64_fill        ... bench:         128 ns/iter (+/- 2) = 8000 MB/s
test gen_1kb_u64_gen_array   ... bench:         146 ns/iter (+/- 0) = 7013 MB/s
test gen_1kb_u64_iter_repeat ... bench:         123 ns/iter (+/- 0) = 8325 MB/s
test gen_1kb_u64_sample_iter ... bench:         150 ns/iter (+/- 1) = 6826 MB/s

test result: ok. 0 passed; 0 failed; 0 ignored; 8 measured; 6 filtered out; finished in 8.52s

/// When using `rustc` ≥ 1.51, enable the `min_const_gen` feature to support
/// arrays larger than 32 elements.
/// Note that [`Rng::fill`] and `Standard`'s array support are *not* equivalent:
Expand Down