cleanup test + ensure chain validity
This commit is contained in:
parent
6bda402a12
commit
45224bf6c2
@ -1,8 +1,6 @@
|
|||||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
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};
|
use othello::{board::Board, future_moves::FutureMoves, piece::Piece};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
fn extend_layers_test(depth: usize, expire: usize) {
|
fn extend_layers_test(depth: usize, expire: usize) {
|
||||||
let mut fut = FutureMoves::new(Piece::Black, depth, expire);
|
let mut fut = FutureMoves::new(Piece::Black, depth, expire);
|
||||||
@ -15,10 +13,10 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
let mut group = c.benchmark_group(format!("extend_layers (expire {})", EXPIRE));
|
let mut group = c.benchmark_group(format!("extend_layers (expire {})", EXPIRE));
|
||||||
group.measurement_time(Duration::from_secs(10));
|
group.measurement_time(Duration::from_secs(10));
|
||||||
|
|
||||||
for (depth, expire) in (2..6).zip([EXPIRE].iter().cycle()) {
|
for (depth, expire) in (2..6).zip([EXPIRE].into_iter().cycle()) {
|
||||||
group.throughput(Throughput::Elements(depth as u64));
|
group.throughput(Throughput::Elements(depth 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, *expire));
|
b.iter(|| extend_layers_test(*depth, expire));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
group.finish();
|
group.finish();
|
||||||
|
|||||||
@ -53,6 +53,15 @@ fn gen_adj_lookup() -> PosMap<ChainCollection> {
|
|||||||
|
|
||||||
// handle diagonals
|
// handle diagonals
|
||||||
chains.extend(diag_raw(i_chain, j_chain).map(Iterator::collect));
|
chains.extend(diag_raw(i_chain, j_chain).map(Iterator::collect));
|
||||||
|
|
||||||
|
// make sure all chains are in the proper range so we can ignore bounds checking later
|
||||||
|
assert!(
|
||||||
|
chains.iter().all(|x| x.iter().all(
|
||||||
|
|(i, j)| (0..BOARD_SIZE).contains(i) && (0..BOARD_SIZE).contains(j)
|
||||||
|
)),
|
||||||
|
"chains go out-of-bounds"
|
||||||
|
);
|
||||||
|
|
||||||
chains
|
chains
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user