othello/benches/future_children.rs

39 lines
1.2 KiB
Rust

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use othello::{
logic::{FutureMoveConfig, FutureMoves},
repr::{Board, Piece},
};
use std::time::Duration;
fn extend_layers_test(depth: usize) {
let config = FutureMoveConfig {
max_depth: depth,
start_pruning_at_minus: 4,
top_k_children: 2,
up_to_mod: 4,
max_arena_size: 10_000_000,
};
let mut fut = FutureMoves::new(Piece::Black, config);
fut.set_root_from_board(Board::new().starting_pos());
fut.extend_layers();
}
fn criterion_benchmark(c: &mut Criterion) {
const EXPIRE: usize = 4;
let mut group = c.benchmark_group(format!("extend_layers (expire {})", EXPIRE));
group.measurement_time(Duration::from_secs(10));
group.sample_size(1000);
for depth in 4..8 {
// TODO! maybe somehow get throughput from `extend_layers`?
// group.throughput(Throughput::Elements(depth as u64));
group.bench_with_input(BenchmarkId::from_parameter(depth), &depth, |b, depth| {
b.iter(|| extend_layers_test(*depth));
});
}
group.finish();
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);