Parallelize parking lot spot generation. Austin goes from 81s total import down to 44s.
use std::collections::HashSet;
-use abstutil::Timer;
+use abstutil::{Parallelism, Timer};
use geom::{Angle, Distance, FindClosest, HashablePt2D, Line, PolyLine, Polygon, Pt2D, Ring};
use crate::make::match_points_to_lanes;
@@ -151,21 +151,24 @@ pub fn make_all_parking_lots(
}
}
- timer.start_iter("generate parking lot spots", results.len());
- for lot in results.iter_mut() {
- timer.next();
+ let results = timer.parallelize(
+ "generate parking lot spots",
+ Parallelism::Fastest,
+ results,
+ |mut lot| {
lot.spots = infer_spots(&lot.polygon, &lot.aisles);
// Guess how many extra spots are available, that maybe aren't renderable.
if lot.spots.is_empty() {
- // No parking aisles. Just guess based on the area. One spot per 30m^2 is a quick guess
- // from looking at examples with aisles.
+ // No parking aisles. Just guess based on the area. One spot per 30m^2 is a quick
+ // guess from looking at examples with aisles.
lot.extra_spots = (lot.polygon.area() / 30.0) as usize;
}
- }
+ lot
+ },
+ );
timer.stop("convert parking lots");
-
results
}
