Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
149 changes: 7 additions & 142 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/benches/factor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false

[dev-dependencies]
array-init = "2.0.0"
criterion = "0.6.0"
divan = { workspace = true }
rand = "0.9.1"
rand_chacha = "0.9.0"
num-prime = "0.4.4"
Expand Down
34 changes: 16 additions & 18 deletions tests/benches/factor/benches/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
// spell-checker:ignore funcs

use array_init::array_init;
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use divan::Bencher;

fn table(c: &mut Criterion) {
fn main() {
divan::main();
}

#[divan::bench()]
fn factor_table(bencher: Bencher) {
#[cfg(target_os = "linux")]
check_personality();

Expand All @@ -22,21 +27,17 @@ fn table(c: &mut Criterion) {
let mut rng = ChaCha8Rng::seed_from_u64(SEED);

std::iter::repeat_with(move || array_init::<_, _, INPUT_SIZE>(|_| rng.next_u64()))
.take(10)
.collect::<Vec<_>>()
};

let mut group = c.benchmark_group("table");
group.throughput(Throughput::Elements(INPUT_SIZE as _));
for a in inputs.take(10) {
let a_str = format!("{a:?}");
group.bench_with_input(BenchmarkId::new("factor", &a_str), &a, |b, &a| {
b.iter(|| {
for n in a {
let _r = num_prime::nt_funcs::factors(n, None);
}
});
});
}
group.finish();
bencher.bench(|| {
for a in &inputs {
for n in a {
divan::black_box(num_prime::nt_funcs::factors(*n, None));
}
}
});
}

#[cfg(target_os = "linux")]
Expand All @@ -59,6 +60,3 @@ fn check_personality() {
);
}
}

criterion_group!(benches, table);
criterion_main!(benches);
Loading