benchmark improvements
This commit is contained in:
@@ -1,33 +1,36 @@
|
|||||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
||||||
use othello::{
|
use othello::{
|
||||||
logic::{FutureMoveConfig, FutureMoves},
|
logic::{FutureMoveConfig, FutureMoves},
|
||||||
repr::{Board, Piece},
|
repr::{Board, Piece},
|
||||||
};
|
};
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
fn extend_layers_test(depth: usize) {
|
fn extend_layers_test(depth: usize, arena_size: usize) -> usize {
|
||||||
let config = FutureMoveConfig {
|
let config = FutureMoveConfig {
|
||||||
max_depth: depth,
|
max_depth: depth,
|
||||||
min_arena_depth_sub: 4,
|
min_arena_depth_sub: 4,
|
||||||
top_k_children: 2,
|
top_k_children: 2,
|
||||||
up_to_minus: 4,
|
up_to_minus: usize::MAX, // disable pruning
|
||||||
max_arena_size: 10_000_000,
|
max_arena_size: arena_size,
|
||||||
};
|
};
|
||||||
let mut fut = FutureMoves::new(Piece::Black, config);
|
let mut fut = FutureMoves::new(Piece::Black, config);
|
||||||
fut.set_root_from_board(Board::new().starting_pos());
|
fut.set_root_from_board(Board::new().starting_pos());
|
||||||
fut.extend_layers();
|
fut.extend_layers();
|
||||||
|
fut.arena_len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn criterion_benchmark(c: &mut Criterion) {
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
let mut group = c.benchmark_group("extend_layer");
|
let mut group = c.benchmark_group("extend_layer");
|
||||||
group.measurement_time(Duration::from_secs(10));
|
// group.measurement_time(Duration::from_secs(10));
|
||||||
group.sample_size(1000);
|
// group.sample_size(1000);
|
||||||
|
|
||||||
|
const ARENA_SIZE: usize = 10_000_000;
|
||||||
|
|
||||||
for depth in 1..8 {
|
for depth in 1..8 {
|
||||||
// TODO! maybe somehow get throughput from `extend_layers`?
|
group.throughput(Throughput::Elements(
|
||||||
// group.throughput(Throughput::Elements(depth as u64));
|
extend_layers_test(depth, ARENA_SIZE) as u64
|
||||||
|
));
|
||||||
group.bench_with_input(BenchmarkId::from_parameter(depth), &depth, |b, depth| {
|
group.bench_with_input(BenchmarkId::from_parameter(depth), &depth, |b, depth| {
|
||||||
b.iter(|| extend_layers_test(*depth));
|
b.iter(|| extend_layers_test(*depth, ARENA_SIZE));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
group.finish();
|
group.finish();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ fn main() {
|
|||||||
// max_depth: 20,
|
// max_depth: 20,
|
||||||
// min_arena_depth_sub: 3,
|
// min_arena_depth_sub: 3,
|
||||||
// top_k_children: 2,
|
// top_k_children: 2,
|
||||||
// up_to_minus: 5, // disable pruning
|
// up_to_minus: 5,
|
||||||
// max_arena_size: 2_000_000,
|
// max_arena_size: 2_000_000,
|
||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
|
|||||||
Reference in New Issue
Block a user