diff options
| author | mat <git@matdoes.dev> | 2025-08-16 23:23:28 +0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-08-16 23:23:28 +0330 |
| commit | daeb769bac4e0be85750d614cad7e69737106bfc (patch) | |
| tree | 190ceda3e3ad3dc49b108058918d472f902475e3 | |
| parent | 7ae3eceee2a2a5577259b1aa066f97b1314e175d (diff) | |
| download | azalea-drasl-daeb769bac4e0be85750d614cad7e69737106bfc.tar.xz | |
log pathfinder perf info on success
| -rw-r--r-- | azalea/src/pathfinder/astar.rs | 21 |
1 files 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 { |
