From daeb769bac4e0be85750d614cad7e69737106bfc Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 16 Aug 2025 23:23:28 +0330 Subject: log pathfinder perf info on success --- azalea/src/pathfinder/astar.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs index da11e352..b2559c1f 100644 --- a/azalea/src/pathfinder/astar.rs +++ b/azalea/src/pathfinder/astar.rs @@ -73,10 +73,11 @@ where let (&node, node_data) = nodes.get_index(index).unwrap(); if success(node) { - debug!("Nodes considered: {num_nodes}"); + let best_path = index; + log_perf_info(start_time, num_nodes, num_movements); return Path { - movements: reconstruct_path(nodes, index, successors), + movements: reconstruct_path(nodes, best_path, successors), is_partial: false, }; } @@ -163,20 +164,26 @@ where } let best_path = determine_best_path(best_paths, 0); + log_perf_info(start_time, num_nodes, num_movements); + Path { + movements: reconstruct_path(nodes, best_path, successors), + is_partial: true, + } +} +fn log_perf_info(start_time: Instant, num_nodes: usize, num_movements: usize) { let elapsed_seconds = start_time.elapsed().as_secs_f64(); let nodes_per_second = (num_nodes as f64 / elapsed_seconds) as u64; let num_movements_per_second = (num_movements as f64 / elapsed_seconds) as u64; + debug!( + "Nodes considered: {}", + num_nodes.to_formatted_string(&num_format::Locale::en) + ); debug!( "A* ran at {} nodes per second and {} movements per second", nodes_per_second.to_formatted_string(&num_format::Locale::en), num_movements_per_second.to_formatted_string(&num_format::Locale::en), ); - - Path { - movements: reconstruct_path(nodes, best_path, successors), - is_partial: true, - } } fn determine_best_path(best_paths: [usize; 7], start: usize) -> usize { -- cgit v1.2.3