Skip to content

Commit

Permalink
Print timing breakdown in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Dec 31, 2024
1 parent ed7e108 commit 4adf4f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl LTN {
name: String,
edit_perimeter_roads: bool,
) -> Result<(), JsValue> {
info!("setCurrentNeighbourhood");
let boundary_gj = self.map.boundaries.get(&name).cloned().unwrap();
let mut boundary_geo: Polygon = boundary_gj.try_into().map_err(err_to_js)?;
self.map.mercator.to_mercator_in_place(&mut boundary_geo);
Expand All @@ -168,7 +167,6 @@ impl LTN {
Neighbourhood::new(&self.map, name, boundary_geo, edit_perimeter_roads)
.map_err(err_to_js)?,
);
info!("done");
Ok(())
}

Expand Down
14 changes: 9 additions & 5 deletions backend/src/neighbourhood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Neighbourhood {
boundary_polygon: Polygon,
edit_perimeter_roads: bool,
) -> Result<Self> {
info!("match roads");
let t1 = Instant::now();
let bbox = buffer_aabb(aabb(&boundary_polygon), 50.0);

let mut interior_roads = BTreeSet::new();
Expand All @@ -66,7 +66,7 @@ impl Neighbourhood {
}
}

info!("match intersections");
let t2 = Instant::now();
let mut border_intersections = BTreeSet::new();
for obj in map
.closest_intersection
Expand All @@ -84,10 +84,14 @@ impl Neighbourhood {
if interior_roads.is_empty() {
bail!("No roads inside the boundary");
}
info!("rest of setup");

// Convert from m^2 to km^2. Use unsigned area to ignore polygon orientation.
let boundary_area_km2 = boundary_polygon.unsigned_area() / 1_000_000.0;
let t3 = Instant::now();

if true {
info!("Neighbourhood set up, total {:?}. Finding roads took {:?}, intersections took {:?}", t3 - t1, t2 - t1, t3 - t2);
}

let mut n = Self {
interior_roads,
Expand Down Expand Up @@ -115,8 +119,8 @@ impl Neighbourhood {
render_cells,
shortcuts,
});
if false {
info!("Neighbourhood edited. Finding cells took {:?}, rendering cells took {:?}, finding shortcuts took {:?}", t2 - t1, t3 - t2, t4 - t3);
if true {
info!("Neighbourhood edited, total {:?}. Finding cells took {:?}, rendering cells took {:?}, finding shortcuts took {:?}", t4 - t1, t2 - t1, t3 - t2, t4 - t3);
}
}

Expand Down

0 comments on commit 4adf4f0

Please sign in to comment.