From df9d9b8c616d50c426591b8771f21dc454bc9893 Mon Sep 17 00:00:00 2001 From: sascha Date: Fri, 10 Jan 2025 15:46:11 +0100 Subject: [PATCH] added tree simulate bench --- src/logic/depth_first/simulation/d_tree.rs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/logic/depth_first/simulation/d_tree.rs b/src/logic/depth_first/simulation/d_tree.rs index b28dca7..e533710 100644 --- a/src/logic/depth_first/simulation/d_tree.rs +++ b/src/logic/depth_first/simulation/d_tree.rs @@ -368,6 +368,8 @@ impl Display for DTree { mod tests { use std::time::Duration; + use test::bench; + use crate::{ logic::depth_first::{ game::{ @@ -388,6 +390,28 @@ mod tests { read_game_state, }; + #[bench] + fn bench_tree_simulate(b: &mut bench::Bencher) { + let gamestate = read_game_state("requests/test_move_request.json"); + let state = DGameState::::from_request( + &gamestate.board, + &gamestate.you, + &gamestate.turn, + ); + + b.iter(|| { + let root = DFullSimulationNode::new( + DNodeId::default(), + vec![state.clone()], + DTreeTime::default(), + DNodeStatus::default(), + None, + ); + let mut tree = DTree::default().root(root).max_depth(4); + tree.simulate() + }); + } + #[test] fn test_simulate_with_pessimistic_capture_node() { let gamestate = read_game_state("requests/test_move_request.json");