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}; fn future_move_bench(depth: usize, expire: usize) { let mut fut = FutureMoves::new(Piece::Black, depth, expire); fut.update(&Board::new().starting_pos()); let _best_move = fut.best_move().inspect(|&(i, j)| { if !fut.update_root_coord(i, j) { panic!("update_root_coord failed"); } }); } fn criterion_benchmark(c: &mut Criterion) { 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); criterion_main!(benches);