Improve tracing output

This commit is contained in:
hal8174 2025-02-17 23:08:06 +01:00
parent cebdee4ec7
commit 81edc8e67a
6 changed files with 53 additions and 24 deletions

View file

@ -276,7 +276,6 @@ impl Problem {
end: self.end[i],
};
let p = {
let _pathfinding_span = span!(Level::TRACE, "graph").entered();
// dijkstra::<MapInternal, FastBinaryHeap<_>>(&m, self.start[i], self.end[i])
a_star::<MapInternal, FastBinaryHeap<_>, _>(
&m,

View file

@ -1,5 +1,7 @@
use std::{collections::HashMap, fmt::Debug, hash::Hash, hash::Hasher};
use tracing::{field::Empty, trace, trace_span};
use crate::priority_queue::PriorityQueue;
use super::WheightedGraph;
@ -61,6 +63,7 @@ where
G::Node: Eq + Hash + Clone + Debug,
G: WheightedGraph,
{
let span = trace_span!("graph", seen_nodes = Empty, visited_nodes = Empty).entered();
if start == end {
return Some(vec![start]);
}
@ -70,7 +73,10 @@ where
let mut q = P::new();
q.insert(QueueObject::new(start.clone(), 0.0));
let mut visited_nodes: usize = 1;
while let Some(o) = q.pop_min() {
visited_nodes += 1;
if let Some(m) = map.get_mut(&o.node) {
m.key = None;
}
@ -97,6 +103,9 @@ where
// dbg!(&q);
}
span.record("seen_nodes", map.len());
span.record("visited_nodes", visited_nodes);
map.get(&end)?;
let mut result = vec![end];