improve benchmarks and marginal perf improvements

This commit is contained in:
2025-02-18 16:27:04 -05:00
parent 1972707f88
commit 0fea3da31c
3 changed files with 32 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
use std::hint::black_box;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use std::time::Duration;
// use crate::future_move::FutureMove;
use othello::{board::Board, future_moves::FutureMoves, piece::Piece};
@@ -15,9 +15,16 @@ fn future_move_bench(depth: usize, expire: usize) {
}
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("depth 6 expire 4", |b| {
b.iter(|| future_move_bench(black_box(6), black_box(4)))
});
let mut group = c.benchmark_group("future_move (expire 4)");
group.measurement_time(Duration::from_secs(60));
for (depth, expire) in [(2, 4), (3, 4), (4, 4), (5, 4), (6, 4)].iter() {
group.throughput(Throughput::Elements(*depth as u64));
group.bench_with_input(BenchmarkId::from_parameter(depth), depth, |b, depth| {
b.iter(|| future_move_bench(*depth, *expire));
});
}
group.finish();
}
criterion_group!(benches, criterion_benchmark);