Skip to content

Commit

Permalink
More benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Jul 30, 2024
1 parent 7592014 commit 1df9918
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions benches/lambert_benches.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use criterion::{criterion_group, criterion_main, Criterion};
use lambert_w::lambert_w_0;
use lambert_w::{lambert_w_0, lambert_w_m1, sp_lambert_w_0, sp_lambert_w_m1};
use std::hint::black_box;

fn ln_vs_lambert_w_0(c: &mut Criterion) {
let args = [
let big_args = [
-2.678794411714424e-01_f64,
6.321205588285577e-01,
9.632120558828557,
Expand All @@ -14,10 +14,25 @@ fn ln_vs_lambert_w_0(c: &mut Criterion) {
1.000000000000000e+160,
];

for z in args {
let mut group = c.benchmark_group(format!("{z}"));
group.bench_function(&format!("ln"), |b| b.iter(|| black_box(z.ln())));
group.bench_function(&format!("W_0"), |b| b.iter(|| black_box(lambert_w_0(z))));
let small_args = [-0.2];

for z in big_args {
let mut group = c.benchmark_group(format!("W_0({z})"));
group.bench_function(&format!("50 bits"), |b| {
b.iter(|| black_box(lambert_w_0(z)))
});
group.bench_function(&format!("24 bits"), |b| {
b.iter(|| black_box(sp_lambert_w_0(z)))
});
}
for z in small_args {
let mut group = c.benchmark_group(format!("W_-1({z})"));
group.bench_function(&format!("50 bits"), |b| {
b.iter(|| black_box(lambert_w_m1(z)))
});
group.bench_function(&format!("24 bits"), |b| {
b.iter(|| black_box(sp_lambert_w_m1(z)))
});
}
}

Expand Down

0 comments on commit 1df9918

Please sign in to comment.