performance progress tracking
This commit is contained in:
parent
f1ec0a08d9
commit
e66771dba9
16 changed files with 2816 additions and 121 deletions
15
benches/eval.rs
Normal file
15
benches/eval.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use chess_engine::board::Board;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use chess_engine::eval::basic::evaluate_board;
|
||||
|
||||
fn run_eval_benchmark(c: &mut Criterion) {
|
||||
let board = Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
||||
c.bench_function("standard_board_evaluation", |b| {
|
||||
b.iter(|| {
|
||||
evaluate_board(&board);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, run_eval_benchmark);
|
||||
criterion_main!(benches);
|
||||
36
benches/perft.rs
Normal file
36
benches/perft.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use chess_engine::board::Board;
|
||||
use chess_engine::movegen::generate_pseudo_legal_moves;
|
||||
use chess_engine::movegen::legal_check::is_other_king_attacked;
|
||||
use chess_engine::r#move::MoveList;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
fn count_legal_moves_recursive(board: &mut Board, depth: u8) -> u64 {
|
||||
if depth == 0 {
|
||||
return 1_u64;
|
||||
}
|
||||
let mut list = MoveList::new();
|
||||
generate_pseudo_legal_moves(&board, &mut list);
|
||||
let mut leaf_nodes = 0_u64;
|
||||
for mv in list.iter() {
|
||||
let undo_info = board.make_move(*mv);
|
||||
if !is_other_king_attacked(board) {
|
||||
leaf_nodes += count_legal_moves_recursive(board, depth - 1);
|
||||
}
|
||||
board.undo_move(undo_info);
|
||||
}
|
||||
leaf_nodes
|
||||
}
|
||||
|
||||
|
||||
fn run_perft_benchmark(c: &mut Criterion) {
|
||||
let mut board = Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
||||
|
||||
c.bench_function("standard_perft5", |b| {
|
||||
b.iter(|| {
|
||||
assert_eq!(count_legal_moves_recursive(&mut board, 5), 4865609);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, run_perft_benchmark);
|
||||
criterion_main!(benches);
|
||||
Loading…
Add table
Add a link
Reference in a new issue