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

Range syntax distribution #9

Closed
wants to merge 2 commits into from

Conversation

oli-obk
Copy link

@oli-obk oli-obk commented Feb 6, 2015

removed the Range type and uses the range syntax instead.

Yes, picking out single random numbers is slower than before. The subtraction and modulo are done "every" time. Inlining and optimizations should kill them in most cases. Also generating random numbers is some powers slower than the subtract and mod.

benchmarks with PR

test bench::rand_isaac                                    ... bench:       651 ns/iter (+/- 52) = 1228 MB/s
test bench::rand_isaac64                                  ... bench:       358 ns/iter (+/- 24) = 2234 MB/s
test bench::rand_shuffle_100                              ... bench:      1661 ns/iter (+/- 130)
test bench::rand_std                                      ... bench:       379 ns/iter (+/- 14) = 2110 MB/s
test bench::rand_xorshift                                 ... bench:         0 ns/iter (+/- 0) = 800000 MB/s
test distributions::exponential::bench::rand_exp          ... bench:       868 ns/iter (+/- 42) = 921 MB/s
test distributions::gamma::bench::bench_gamma_large_shape ... bench:      2214 ns/iter (+/- 158) = 361 MB/s
test distributions::gamma::bench::bench_gamma_small_shape ... bench:      2421 ns/iter (+/- 41) = 330 MB/s
test distributions::normal::bench::rand_normal            ... bench:       612 ns/iter (+/- 53) = 1307 MB/s
test distributions::range::bench::rand_float              ... bench:       183 ns/iter (+/- 12) = 4371 MB/s
test distributions::range::bench::rand_int                ... bench:       148 ns/iter (+/- 3) = 5405 MB/s

benchmarks w/o PR (but added the same benchmark code)

test bench::rand_isaac                                    ... bench:       635 ns/iter (+/- 42) = 1259 MB/s
test bench::rand_isaac64                                  ... bench:       358 ns/iter (+/- 24) = 2234 MB/s
test bench::rand_shuffle_100                              ... bench:      1661 ns/iter (+/- 131)
test bench::rand_std                                      ... bench:       366 ns/iter (+/- 19) = 2185 MB/s
test bench::rand_xorshift                                 ... bench:         0 ns/iter (+/- 0) = 800000 MB/s
test distributions::exponential::bench::rand_exp          ... bench:       836 ns/iter (+/- 118) = 956 MB/s
test distributions::gamma::bench::bench_gamma_large_shape ... bench:      2166 ns/iter (+/- 149) = 369 MB/s
test distributions::gamma::bench::bench_gamma_small_shape ... bench:      2411 ns/iter (+/- 94) = 331 MB/s
test distributions::normal::bench::rand_normal            ... bench:       609 ns/iter (+/- 51) = 1313 MB/s
test distributions::range::bench::rand_float              ... bench:       183 ns/iter (+/- 15) = 4371 MB/s
test distributions::range::bench::rand_int                ... bench:       150 ns/iter (+/- 6) = 5333 MB/s

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@alexcrichton
Copy link
Contributor

r? @huonw

@rust-highfive rust-highfive assigned huonw and unassigned alexcrichton Feb 6, 2015
@huonw
Copy link
Contributor

huonw commented Feb 8, 2015

Hi, @oli-obk, thanks for the PR, it looks great, but I'm not keen on merging it now. I took a similar approach in the design I proposed in rust-lang/rfcs#722, I'd prefer to not do a breaking change here when the intention is to move towards something more like that, that is, do one breaking change instead of two.

Thanks for the PR, though!

@huonw huonw closed this Feb 8, 2015
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.

4 participants