bench: add board place benchmark
This commit is contained in:
29
benches/board.rs
Normal file
29
benches/board.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
||||
use othello::repr::{Board, Piece};
|
||||
|
||||
fn fill_board(loops: usize) {
|
||||
let mut board = Board::new();
|
||||
board.place_unchecked((0, 1).into(), Piece::White);
|
||||
board.place_unchecked((0, 2).into(), Piece::Black);
|
||||
board.place_unchecked((0, 3).into(), Piece::Black);
|
||||
board.place_unchecked((0, 4).into(), Piece::Black);
|
||||
for _ in 0..loops {
|
||||
let mut board = board;
|
||||
let _ = board.place((0, 5).into(), Piece::White);
|
||||
}
|
||||
}
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("board");
|
||||
|
||||
const LOOPS: usize = 1000;
|
||||
|
||||
group.throughput(Throughput::Elements(LOOPS as u64));
|
||||
group.bench_function("board_place", |b| {
|
||||
b.iter(|| fill_board(LOOPS));
|
||||
});
|
||||
group.finish();
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
@@ -22,7 +22,7 @@ fn criterion_benchmark(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("extend_layer (no pruning)");
|
||||
const ARENA_SIZE: usize = 10_000_000;
|
||||
|
||||
for depth in 1..8 {
|
||||
for depth in 6..8 {
|
||||
group.throughput(Throughput::Elements(
|
||||
extend_layers_no_pruning(depth, ARENA_SIZE) as u64,
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user