Skip to content

Commit 5610bda

Browse files
authored
Merge pull request #823 from dhardy/master
Bump versions + Edition 2018 + Pcg64
2 parents db60b35 + 7690c21 commit 5610bda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+356
-225
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ before_install:
268268

269269
script:
270270
- cargo test --tests --no-default-features
271-
- cargo test --no-default-features --features getrandom
271+
- cargo test --tests --no-default-features --features getrandom
272272
# TODO: add simd_support feature:
273273
- cargo test --features=serde1,log
274274
- cargo test --examples

Cargo.toml

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand"
3-
version = "0.7.0-pre.0"
3+
version = "0.7.0-pre.1"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT/Apache-2.0"
66
readme = "README.md"
@@ -55,7 +55,7 @@ members = [
5555

5656
[dependencies]
5757
rand_core = { path = "rand_core", version = "0.5" }
58-
rand_pcg = { path = "rand_pcg", version = "0.1", optional = true }
58+
rand_pcg = { path = "rand_pcg", version = "0.2", optional = true }
5959
# Do not depend on 'getrandom_package' directly; use the 'getrandom' feature!
6060
getrandom_package = { version = "0.1.1", package = "getrandom", optional = true }
6161
log = { version = "0.4", optional = true }
@@ -76,42 +76,18 @@ libc = { version = "0.2.22", default-features = false }
7676
[target.'cfg(not(target_os = "emscripten"))'.dependencies]
7777
rand_chacha = { path = "rand_chacha", version = "0.2" }
7878
[target.'cfg(target_os = "emscripten")'.dependencies]
79-
rand_hc = { path = "rand_hc", version = "0.1" }
79+
rand_hc = { path = "rand_hc", version = "0.2" }
8080

8181
[dev-dependencies]
82-
rand_pcg = { path = "rand_pcg", version = "0.1" }
82+
rand_pcg = { path = "rand_pcg", version = "0.2" }
8383
# Only for benches:
84-
rand_hc = { path = "rand_hc", version = "0.1" }
85-
rand_xoshiro = { path = "rand_xoshiro", version = "0.2" }
86-
rand_isaac = { path = "rand_isaac", version = "0.1" }
87-
rand_xorshift = { path = "rand_xorshift", version = "0.1" }
88-
rand_distr = { path = "rand_distr", version = "0.2" }
84+
rand_hc = { path = "rand_hc", version = "0.2" }
85+
rand_xoshiro = { path = "rand_xoshiro", version = "0.3" }
86+
rand_isaac = { path = "rand_isaac", version = "0.2" }
87+
rand_xorshift = { path = "rand_xorshift", version = "0.2" }
8988

9089
[build-dependencies]
9190
autocfg = "0.1"
9291

93-
[[bench]]
94-
name = "distributions"
95-
path = "benches/distributions.rs"
96-
required-features = ["small_rng"]
97-
98-
[[bench]]
99-
name = "generators"
100-
path = "benches/generators.rs"
101-
required-features = ["small_rng"]
102-
103-
[[bench]]
104-
name = "misc"
105-
path = "benches/misc.rs"
106-
required-features = ["small_rng"]
107-
108-
[[bench]]
109-
name = "seq"
110-
path = "benches/seq.rs"
111-
required-features = ["small_rng"]
112-
11392
[package.metadata.docs.rs]
11493
all-features = true
115-
116-
[patch.crates-io]
117-
rand_core = { path = "rand_core", version = "0.5" }

benches/generators.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rand::rngs::OsRng;
3030
use rand_isaac::{IsaacRng, Isaac64Rng};
3131
use rand_chacha::{ChaCha20Core, ChaCha8Rng, ChaCha12Rng, ChaCha20Rng};
3232
use rand_hc::{Hc128Rng};
33-
use rand_pcg::{Lcg64Xsh32, Mcg128Xsl64};
33+
use rand_pcg::{Pcg32, Pcg64, Pcg64Mcg};
3434
use rand_xorshift::XorShiftRng;
3535
use rand_xoshiro::{Xoshiro256StarStar, Xoshiro256Plus, Xoshiro128StarStar,
3636
Xoshiro128Plus, Xoroshiro128StarStar, Xoroshiro128Plus, SplitMix64,
@@ -63,15 +63,17 @@ gen_bytes!(gen_bytes_xoroshiro128plus, Xoroshiro128Plus::from_entropy());
6363
gen_bytes!(gen_bytes_xoroshiro64starstar, Xoroshiro64StarStar::from_entropy());
6464
gen_bytes!(gen_bytes_xoroshiro64star, Xoroshiro64Star::from_entropy());
6565
gen_bytes!(gen_bytes_splitmix64, SplitMix64::from_entropy());
66-
gen_bytes!(gen_bytes_lcg64_xsh32, Lcg64Xsh32::from_entropy());
67-
gen_bytes!(gen_bytes_mcg128_xsh64, Mcg128Xsl64::from_entropy());
66+
gen_bytes!(gen_bytes_pcg32, Pcg32::from_entropy());
67+
gen_bytes!(gen_bytes_pcg64, Pcg64::from_entropy());
68+
gen_bytes!(gen_bytes_pcg64mcg, Pcg64Mcg::from_entropy());
6869
gen_bytes!(gen_bytes_chacha8, ChaCha8Rng::from_entropy());
6970
gen_bytes!(gen_bytes_chacha12, ChaCha12Rng::from_entropy());
7071
gen_bytes!(gen_bytes_chacha20, ChaCha20Rng::from_entropy());
7172
gen_bytes!(gen_bytes_hc128, Hc128Rng::from_entropy());
7273
gen_bytes!(gen_bytes_isaac, IsaacRng::from_entropy());
7374
gen_bytes!(gen_bytes_isaac64, Isaac64Rng::from_entropy());
7475
gen_bytes!(gen_bytes_std, StdRng::from_entropy());
76+
#[cfg(feature="small_rng")]
7577
gen_bytes!(gen_bytes_small, SmallRng::from_entropy());
7678
gen_bytes!(gen_bytes_os, OsRng);
7779

@@ -102,15 +104,17 @@ gen_uint!(gen_u32_xoroshiro128plus, u32, Xoroshiro128Plus::from_entropy());
102104
gen_uint!(gen_u32_xoroshiro64starstar, u32, Xoroshiro64StarStar::from_entropy());
103105
gen_uint!(gen_u32_xoroshiro64star, u32, Xoroshiro64Star::from_entropy());
104106
gen_uint!(gen_u32_splitmix64, u32, SplitMix64::from_entropy());
105-
gen_uint!(gen_u32_lcg64_xsh32, u32, Lcg64Xsh32::from_entropy());
106-
gen_uint!(gen_u32_mcg128_xsh64, u32, Mcg128Xsl64::from_entropy());
107+
gen_uint!(gen_u32_pcg32, u32, Pcg32::from_entropy());
108+
gen_uint!(gen_u32_pcg64, u32, Pcg64::from_entropy());
109+
gen_uint!(gen_u32_pcg64mcg, u32, Pcg64Mcg::from_entropy());
107110
gen_uint!(gen_u32_chacha8, u32, ChaCha8Rng::from_entropy());
108111
gen_uint!(gen_u32_chacha12, u32, ChaCha12Rng::from_entropy());
109112
gen_uint!(gen_u32_chacha20, u32, ChaCha20Rng::from_entropy());
110113
gen_uint!(gen_u32_hc128, u32, Hc128Rng::from_entropy());
111114
gen_uint!(gen_u32_isaac, u32, IsaacRng::from_entropy());
112115
gen_uint!(gen_u32_isaac64, u32, Isaac64Rng::from_entropy());
113116
gen_uint!(gen_u32_std, u32, StdRng::from_entropy());
117+
#[cfg(feature="small_rng")]
114118
gen_uint!(gen_u32_small, u32, SmallRng::from_entropy());
115119
gen_uint!(gen_u32_os, u32, OsRng);
116120

@@ -124,15 +128,17 @@ gen_uint!(gen_u64_xoroshiro128plus, u64, Xoroshiro128Plus::from_entropy());
124128
gen_uint!(gen_u64_xoroshiro64starstar, u64, Xoroshiro64StarStar::from_entropy());
125129
gen_uint!(gen_u64_xoroshiro64star, u64, Xoroshiro64Star::from_entropy());
126130
gen_uint!(gen_u64_splitmix64, u64, SplitMix64::from_entropy());
127-
gen_uint!(gen_u64_lcg64_xsh32, u64, Lcg64Xsh32::from_entropy());
128-
gen_uint!(gen_u64_mcg128_xsh64, u64, Mcg128Xsl64::from_entropy());
131+
gen_uint!(gen_u64_pcg32, u64, Pcg32::from_entropy());
132+
gen_uint!(gen_u64_pcg64, u64, Pcg64::from_entropy());
133+
gen_uint!(gen_u64_pcg64mcg, u64, Pcg64Mcg::from_entropy());
129134
gen_uint!(gen_u64_chacha8, u64, ChaCha8Rng::from_entropy());
130135
gen_uint!(gen_u64_chacha12, u64, ChaCha12Rng::from_entropy());
131136
gen_uint!(gen_u64_chacha20, u64, ChaCha20Rng::from_entropy());
132137
gen_uint!(gen_u64_hc128, u64, Hc128Rng::from_entropy());
133138
gen_uint!(gen_u64_isaac, u64, IsaacRng::from_entropy());
134139
gen_uint!(gen_u64_isaac64, u64, Isaac64Rng::from_entropy());
135140
gen_uint!(gen_u64_std, u64, StdRng::from_entropy());
141+
#[cfg(feature="small_rng")]
136142
gen_uint!(gen_u64_small, u64, SmallRng::from_entropy());
137143
gen_uint!(gen_u64_os, u64, OsRng);
138144

@@ -159,8 +165,9 @@ init_gen!(init_xoroshiro128plus, Xoroshiro128Plus);
159165
init_gen!(init_xoroshiro64starstar, Xoroshiro64StarStar);
160166
init_gen!(init_xoroshiro64star, Xoroshiro64Star);
161167
init_gen!(init_splitmix64, SplitMix64);
162-
init_gen!(init_lcg64_xsh32, Lcg64Xsh32);
163-
init_gen!(init_mcg128_xsh64, Mcg128Xsl64);
168+
init_gen!(init_pcg32, Pcg32);
169+
init_gen!(init_pcg64, Pcg64);
170+
init_gen!(init_pcg64mcg, Pcg64Mcg);
164171
init_gen!(init_hc128, Hc128Rng);
165172
init_gen!(init_isaac, IsaacRng);
166173
init_gen!(init_isaac64, Isaac64Rng);

benches/misc.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010

1111
extern crate test;
1212
extern crate rand;
13+
extern crate rand_pcg;
1314

1415
const RAND_BENCH_N: u64 = 1000;
1516

1617
use test::Bencher;
1718

1819
use rand::prelude::*;
1920
use rand::distributions::{Distribution, Standard, Bernoulli};
21+
use rand_pcg::{Pcg32, Pcg64Mcg};
2022

2123
#[bench]
2224
fn misc_gen_bool_const(b: &mut Bencher) {
23-
let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
25+
let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
2426
b.iter(|| {
2527
let mut accum = true;
2628
for _ in 0..::RAND_BENCH_N {
@@ -32,7 +34,7 @@ fn misc_gen_bool_const(b: &mut Bencher) {
3234

3335
#[bench]
3436
fn misc_gen_bool_var(b: &mut Bencher) {
35-
let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
37+
let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
3638
b.iter(|| {
3739
let mut accum = true;
3840
let mut p = 0.18;
@@ -46,7 +48,7 @@ fn misc_gen_bool_var(b: &mut Bencher) {
4648

4749
#[bench]
4850
fn misc_gen_ratio_const(b: &mut Bencher) {
49-
let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
51+
let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
5052
b.iter(|| {
5153
let mut accum = true;
5254
for _ in 0..::RAND_BENCH_N {
@@ -58,7 +60,7 @@ fn misc_gen_ratio_const(b: &mut Bencher) {
5860

5961
#[bench]
6062
fn misc_gen_ratio_var(b: &mut Bencher) {
61-
let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
63+
let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
6264
b.iter(|| {
6365
let mut accum = true;
6466
for i in 2..(::RAND_BENCH_N as u32 + 2) {
@@ -70,7 +72,7 @@ fn misc_gen_ratio_var(b: &mut Bencher) {
7072

7173
#[bench]
7274
fn misc_bernoulli_const(b: &mut Bencher) {
73-
let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
75+
let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
7476
b.iter(|| {
7577
let d = rand::distributions::Bernoulli::new(0.18).unwrap();
7678
let mut accum = true;
@@ -83,7 +85,7 @@ fn misc_bernoulli_const(b: &mut Bencher) {
8385

8486
#[bench]
8587
fn misc_bernoulli_var(b: &mut Bencher) {
86-
let mut rng = StdRng::from_rng(&mut thread_rng()).unwrap();
88+
let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
8789
b.iter(|| {
8890
let mut accum = true;
8991
let mut p = 0.18;
@@ -99,7 +101,7 @@ fn misc_bernoulli_var(b: &mut Bencher) {
99101
#[bench]
100102
fn gen_1k_iter_repeat(b: &mut Bencher) {
101103
use std::iter;
102-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
104+
let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
103105
b.iter(|| {
104106
let v: Vec<u64> = iter::repeat(()).map(|()| rng.gen()).take(128).collect();
105107
v
@@ -109,7 +111,7 @@ fn gen_1k_iter_repeat(b: &mut Bencher) {
109111

110112
#[bench]
111113
fn gen_1k_sample_iter(b: &mut Bencher) {
112-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
114+
let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
113115
b.iter(|| {
114116
let v: Vec<u64> = Standard.sample_iter(&mut rng).take(128).collect();
115117
v
@@ -119,7 +121,7 @@ fn gen_1k_sample_iter(b: &mut Bencher) {
119121

120122
#[bench]
121123
fn gen_1k_gen_array(b: &mut Bencher) {
122-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
124+
let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
123125
b.iter(|| {
124126
// max supported array length is 32!
125127
let v: [[u64; 32]; 4] = rng.gen();
@@ -130,7 +132,7 @@ fn gen_1k_gen_array(b: &mut Bencher) {
130132

131133
#[bench]
132134
fn gen_1k_fill(b: &mut Bencher) {
133-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
135+
let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
134136
let mut buf = [0u64; 128];
135137
b.iter(|| {
136138
rng.fill(&mut buf[..]);

benches/seq.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111

1212
extern crate test;
1313
extern crate rand;
14+
extern crate rand_pcg;
1415

1516
use test::Bencher;
1617

1718
use rand::prelude::*;
1819
use rand::seq::*;
1920
use std::mem::size_of;
2021

22+
// We force use of 32-bit RNG since seq code is optimised for use with 32-bit
23+
// generators on all platforms.
24+
use rand_pcg::Pcg32 as SmallRng;
25+
2126
const RAND_BENCH_N: u64 = 1000;
2227

2328
#[bench]

rand_distr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ appveyor = { repository = "rust-random/rand" }
2222
rand = { path = "..", version = ">=0.5, <=0.7.0-pre.9" }
2323

2424
[dev-dependencies]
25-
rand_pcg = { version = "0.1", path = "../rand_pcg" }
25+
rand_pcg = { version = "0.2", path = "../rand_pcg" }
2626
# Histogram implementation for testing uniformity
2727
average = "0.9.2"

0 commit comments

Comments
 (0)