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

Make sure BTPE is not entered when np < 10 #1484

Merged
merged 26 commits into from
Oct 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8c229a4
Make sure BTPE is not entered when np < 10
benjamin-lieser Aug 5, 2024
a1c5229
Use Poisson when BINV would fail because of q == 1.0
benjamin-lieser Aug 5, 2024
1928b8c
binomial enable precomputation of values
benjamin-lieser Aug 15, 2024
9354f9b
serde impls
benjamin-lieser Aug 15, 2024
afb619d
benches/distr: use g.finish()
dhardy Sep 13, 2024
f91933b
benches/distr: revise groups/names
dhardy Sep 13, 2024
0105cbe
benches/distr: reduce warm-up and measurement time
dhardy Sep 13, 2024
307c4a9
benches/distr: use elements, not bytes; remove most sample loops
dhardy Sep 13, 2024
5ca3b18
benches/distr: inline distr!
dhardy Sep 13, 2024
3bb85ca
benches/distr: expand Poisson benchmarks
dhardy Sep 13, 2024
8c4b34e
Poisson: split repr into two enum variants
dhardy Sep 13, 2024
2dee225
Make poisson::KnuthMethod pub(crate)
dhardy Sep 13, 2024
361404e
Merge remote-tracking branch 'dhardy/poisson-enum' into binomial_nume…
benjamin-lieser Sep 13, 2024
aaa08df
Use Knuth Method in Binomial to save space in the Binomial struct
benjamin-lieser Sep 13, 2024
a8bfec1
serde impls
benjamin-lieser Sep 13, 2024
a007613
rename inner to method
benjamin-lieser Sep 13, 2024
b0021aa
remove the known issue from doc
benjamin-lieser Sep 13, 2024
2f6cef5
rustfmt and changelog
benjamin-lieser Sep 13, 2024
333f302
code comments and inline attr
benjamin-lieser Sep 13, 2024
487177c
rustfmt
benjamin-lieser Sep 13, 2024
32e16b3
merge with final poisson
benjamin-lieser Sep 24, 2024
32a6655
remove inline
benjamin-lieser Sep 24, 2024
7a66486
move flipped and n into variants
benjamin-lieser Sep 30, 2024
0318978
correct CHANGELOG
benjamin-lieser Oct 1, 2024
fd9d620
put flipped directly into the enum variants
benjamin-lieser Oct 1, 2024
9fb68a0
replace npq with m
benjamin-lieser Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
benches/distr: use g.finish()
  • Loading branch information
dhardy committed Sep 13, 2024
commit afb619d67ce111896fe93833be986cbfcee855c1
42 changes: 14 additions & 28 deletions benches/benches/distr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ macro_rules! sample_binomial {
}

fn bench(c: &mut Criterion<CyclesPerByte>) {
{
let mut g = c.benchmark_group("exp");
distr_float!(g, "exp", f64, Exp::new(1.23 * 4.56).unwrap());
distr_float!(g, "exp1_specialized", f64, Exp1);
distr_float!(g, "exp1_general", f64, Exp::new(1.).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("normal");
distr_float!(g, "normal", f64, Normal::new(-1.23, 4.56).unwrap());
distr_float!(g, "standardnormal_specialized", f64, StandardNormal);
Expand All @@ -139,42 +137,36 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
accum
});
});
}
g.finish();

{
let mut g = c.benchmark_group("skew_normal");
distr_float!(g, "shape_zero", f64, SkewNormal::new(0.0, 1.0, 0.0).unwrap());
distr_float!(g, "shape_positive", f64, SkewNormal::new(0.0, 1.0, 100.0).unwrap());
distr_float!(g, "shape_negative", f64, SkewNormal::new(0.0, 1.0, -100.0).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("gamma");
distr_float!(g, "gamma_large_shape", f64, Gamma::new(10., 1.0).unwrap());
distr_float!(g, "gamma_small_shape", f64, Gamma::new(0.1, 1.0).unwrap());
distr_float!(g, "beta_small_param", f64, Beta::new(0.1, 0.1).unwrap());
distr_float!(g, "beta_large_param_similar", f64, Beta::new(101., 95.).unwrap());
distr_float!(g, "beta_large_param_different", f64, Beta::new(10., 1000.).unwrap());
distr_float!(g, "beta_mixed_param", f64, Beta::new(0.5, 100.).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("cauchy");
distr_float!(g, "cauchy", f64, Cauchy::new(4.2, 6.9).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("triangular");
distr_float!(g, "triangular", f64, Triangular::new(0., 1., 0.9).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("geometric");
distr_int!(g, "geometric", u64, Geometric::new(0.5).unwrap());
distr_int!(g, "standard_geometric", u64, StandardGeometric);
}
g.finish();

{
let mut g = c.benchmark_group("weighted");
distr_int!(g, "weighted_i8", usize, WeightedIndex::new([1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
distr_int!(g, "weighted_u32", usize, WeightedIndex::new([1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
Expand All @@ -184,9 +176,8 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
distr_int!(g, "weighted_alias_method_u32", usize, WeightedAliasIndex::new(vec![1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
distr_int!(g, "weighted_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());
distr_int!(g, "weighted_alias_method_large_set", usize, WeightedAliasIndex::new((0..10000).rev().chain(1..10001).collect()).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("binomial");
sample_binomial!(g, "binomial", 20, 0.7);
sample_binomial!(g, "binomial_small", 1_000_000, 1e-30);
Expand All @@ -195,33 +186,28 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
sample_binomial!(g, "binomial_100", 100, 0.99);
sample_binomial!(g, "binomial_1000", 1000, 0.01);
sample_binomial!(g, "binomial_1e12", 1_000_000_000_000, 0.2);
}
g.finish();

{
let mut g = c.benchmark_group("poisson");
distr_float!(g, "poisson", f64, Poisson::new(4.0).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("zipf");
distr_float!(g, "zipf", f64, Zipf::new(10, 1.5).unwrap());
distr_float!(g, "zeta", f64, Zeta::new(1.5).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("bernoulli");
distr!(g, "bernoulli", bool, Bernoulli::new(0.18).unwrap());
}
g.finish();

{
let mut g = c.benchmark_group("circle");
distr_arr!(g, "circle", [f64; 2], UnitCircle);
}
g.finish();

{
let mut g = c.benchmark_group("sphere");
distr_arr!(g, "sphere", [f64; 3], UnitSphere);
}
g.finish();
}

criterion_group!(
Expand Down