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

Conversation

vks
Copy link
Collaborator

@vks vks commented Sep 15, 2021

This is a followup to #269.

@@ -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

Copy link
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

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

Perhaps addressing this ambiguity is not worth the effort.

@dhardy dhardy merged commit 2924af6 into rust-random:master Feb 11, 2022
@vks vks deleted the fill-float-doc branch February 14, 2022 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants