Conversation
This allows us to see the effect of any specicalized implementations for `getrandom::u32` or `getrandom::u64`. As expected, on Linux (which just uses the default implementation in `utils.rs`) there is no change: ``` test bench_u32 ... bench: 196.50 ns/iter (+/- 4.85) = 20 MB/s test bench_u32_via_fill ... bench: 198.25 ns/iter (+/- 1.78) = 20 MB/s test bench_u64 ... bench: 196.95 ns/iter (+/- 2.99) = 40 MB/s test bench_u64_via_fill ... bench: 197.62 ns/iter (+/- 2.24) = 40 MB/s ``` but when using the `rdrand` backend (which is specialized), there is a mesurable difference. ``` test bench_u32 ... bench: 16.84 ns/iter (+/- 0.09) = 250 MB/s test bench_u32_via_fill ... bench: 18.40 ns/iter (+/- 0.28) = 222 MB/s test bench_u64 ... bench: 16.62 ns/iter (+/- 0.06) = 500 MB/s test bench_u64_via_fill ... bench: 17.70 ns/iter (+/- 0.08) = 470 MB/s ``` Signed-off-by: Joe Richey <joerichey@google.com>
newpavlov
left a comment
There was a problem hiding this comment.
I don't think we need the bench_*_via_fill benchmarks.
The main reason I added those was to test the effectiveness of the Does it make sense to keep them for this reason? I can add some comments explaining why if you think it's necessary. |
|
Performance was not a motivation for addition of the |
This allows us to see the effect of any specicalized implementations for `getrandom::u32` or `getrandom::u64`. As expected, on Linux (which just uses the default implementation in `utils.rs`) there is no change: ``` test bench_u32 ... bench: 196.50 ns/iter (+/- 4.85) = 20 MB/s test bench_u32_via_fill ... bench: 198.25 ns/iter (+/- 1.78) = 20 MB/s test bench_u64 ... bench: 196.95 ns/iter (+/- 2.99) = 40 MB/s test bench_u64_via_fill ... bench: 197.62 ns/iter (+/- 2.24) = 40 MB/s ``` but when using the `rdrand` backend (which is specialized), there is a mesurable difference. ``` test bench_u32 ... bench: 16.84 ns/iter (+/- 0.09) = 250 MB/s test bench_u32_via_fill ... bench: 18.40 ns/iter (+/- 0.28) = 222 MB/s test bench_u64 ... bench: 16.62 ns/iter (+/- 0.06) = 500 MB/s test bench_u64_via_fill ... bench: 17.70 ns/iter (+/- 0.08) = 470 MB/s ```
This allows us to see the effect of any specicalized implementations for
getrandom::u32orgetrandom::u64. As expected, on Linux (which just uses the default implementation inutils.rs) there is no change:but when using the
rdrandbackend (which is specialized), there is a mesurable difference.