|
6 | 6 | // option. This file may not be copied, modified, or distributed
|
7 | 7 | // except according to those terms.
|
8 | 8 |
|
9 |
| -#![feature(custom_inner_attributes)] |
10 |
| - |
11 |
| -// Rustfmt splits macro invocations to shorten lines; in this case longer-lines are more readable |
12 |
| -#![rustfmt::skip] |
13 |
| - |
14 | 9 | use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
15 | 10 | use criterion_cycles_per_byte::CyclesPerByte;
|
16 | 11 |
|
@@ -80,7 +75,8 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
|
80 | 75 | let distr = Normal::new(-E, PI).unwrap();
|
81 | 76 |
|
82 | 77 | c.iter(|| {
|
83 |
| - distr.sample_iter(&mut rng) |
| 78 | + distr |
| 79 | + .sample_iter(&mut rng) |
84 | 80 | .take(ITER_ELTS as usize)
|
85 | 81 | .fold(0.0, |a, r| a + r)
|
86 | 82 | });
|
@@ -121,12 +117,22 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
|
121 | 117 | let mut g = c.benchmark_group("weighted");
|
122 | 118 | distr_int!(g, "i8", usize, WeightedIndex::new([1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
|
123 | 119 | distr_int!(g, "u32", usize, WeightedIndex::new([1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
|
124 |
| - distr_int!(g, "f64", usize, WeightedIndex::new([1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap()); |
| 120 | + distr_int!(g, "f64", usize, WeightedIndex::new([1.0f64, 0.001, 1.0 / 3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap()); |
125 | 121 | distr_int!(g, "large_set", usize, WeightedIndex::new((0..10000).rev().chain(1..10001)).unwrap());
|
126 | 122 | distr_int!(g, "alias_method_i8", usize, WeightedAliasIndex::new(vec![1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
|
127 | 123 | distr_int!(g, "alias_method_u32", usize, WeightedAliasIndex::new(vec![1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
|
128 |
| - distr_int!(g, "alias_method_f64", usize, WeightedAliasIndex::new(vec![1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap()); |
129 |
| - distr_int!(g, "alias_method_large_set", usize, WeightedAliasIndex::new((0..10000).rev().chain(1..10001).collect()).unwrap()); |
| 124 | + distr_int!( |
| 125 | + g, |
| 126 | + "alias_method_f64", |
| 127 | + usize, |
| 128 | + WeightedAliasIndex::new(vec![1.0f64, 0.001, 1.0 / 3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap() |
| 129 | + ); |
| 130 | + distr_int!( |
| 131 | + g, |
| 132 | + "alias_method_large_set", |
| 133 | + usize, |
| 134 | + WeightedAliasIndex::new((0..10000).rev().chain(1..10001).collect()).unwrap() |
| 135 | + ); |
130 | 136 | g.finish();
|
131 | 137 |
|
132 | 138 | let mut g = c.benchmark_group("binomial");
|
|
0 commit comments