stick in some flamegraph timings to part of map loading

This commit is contained in:
Dustin Carlino 2018-09-08 13:01:36 -07:00
parent ba9fe54c2a
commit 630f6504f4
9 changed files with 30 additions and 5 deletions

View File

@ -9,6 +9,7 @@ abstutil = { path = "../abstutil" }
control = { path = "../control" }
dimensioned = { git = "https://github.com/paholg/dimensioned", rev = "0e1076ebfa5128d1ee544bdc9754c948987b6fe3", features = ["serde"] }
ezgui = { path = "../ezgui" }
flame = "0.2.2"
generator = "0.6"
geo = "0.9.1"
geom = { path = "../geom" }

View File

@ -5,6 +5,7 @@ extern crate abstutil;
extern crate control;
extern crate dimensioned;
extern crate ezgui;
extern crate flame;
#[macro_use]
extern crate generator;
extern crate geo;

View File

@ -10,6 +10,7 @@ use ezgui;
use ezgui::canvas::Canvas;
use ezgui::input::UserInput;
use ezgui::{GfxCtx, ToggleableLayer};
use flame;
use geom::Pt2D;
use graphics::types::Color;
use gui;
@ -104,7 +105,11 @@ impl UI {
Vec::new()
};
flame::start("draw_map");
let (draw_map, center_pt) = render::DrawMap::new(&map, &control_map, extra_shapes);
flame::end("draw_map");
flame::dump_stdout();
let steepness_viz = SteepnessVisualizer::new(&map);
let turn_colors = TurnColors::new(&control_map);

View File

@ -7,6 +7,7 @@ authors = ["Dustin Carlino <dabreegster@gmail.com>"]
abstutil = { path = "../abstutil" }
aabb-quadtree = "0.1.0"
dimensioned = { git = "https://github.com/paholg/dimensioned", rev = "0e1076ebfa5128d1ee544bdc9754c948987b6fe3", features = ["serde"] }
flame = "0.2.2"
geo = "0.9.1"
geom = { path = "../geom" }
gtfs = { path = "../gtfs" }

View File

@ -1,6 +1,7 @@
extern crate aabb_quadtree;
extern crate abstutil;
extern crate dimensioned;
extern crate flame;
extern crate geo;
extern crate geom;
extern crate gtfs;

View File

@ -2,6 +2,7 @@
use abstutil;
use edits::Edits;
use flame;
use geom::{Bounds, HashablePt2D, PolyLine, Pt2D};
use geometry;
use make;
@ -32,7 +33,12 @@ pub struct Map {
impl Map {
pub fn new(path: &str, edits: &Edits) -> Result<Map, Error> {
// TODO I think I want something a bit different than flame:
// - Print as each phase occurs
// - Print with nicely formatted durations
flame::start("read raw_data");
let data: raw_data::Map = abstutil::read_binary(path)?;
flame::end("read raw_data");
Ok(Map::create_from_raw(
path::Path::new(path)
.file_stem()
@ -164,11 +170,14 @@ impl Map {
m.intersections[t.parent.0].turns.push(t.id);
}
for (idx, b) in data.buildings.iter().enumerate() {
let id = BuildingID(idx);
let bldg = make::make_building(b, id, &bounds, &m.lanes);
m.lanes[bldg.front_path.sidewalk.0].building_paths.push(id);
m.buildings.push(bldg);
{
let _guard = flame::start_guard(format!("make {} buildings", data.buildings.len()));
for (idx, b) in data.buildings.iter().enumerate() {
let id = BuildingID(idx);
let bldg = make::make_building(b, id, &bounds, &m.lanes);
m.lanes[bldg.front_path.sidewalk.0].building_paths.push(id);
m.buildings.push(bldg);
}
}
for (idx, p) in data.parcels.iter().enumerate() {

View File

@ -11,6 +11,7 @@ derivative = "1.0.0"
dimensioned = { git = "https://github.com/paholg/dimensioned", rev = "0e1076ebfa5128d1ee544bdc9754c948987b6fe3", features = ["serde"] }
ezgui = { path = "../ezgui" }
failure = "0.1.2"
flame = "0.2.2"
geom = { path = "../geom" }
lazy_static = "1.1.0"
map_model = { path = "../map_model" }

View File

@ -1,5 +1,6 @@
use abstutil;
use control::ControlMap;
use flame;
use map_model::{BuildingID, BusRoute, BusStop, Edits, LaneID, Map};
use rand::Rng;
use std::collections::VecDeque;
@ -16,7 +17,9 @@ pub fn load(
if input.contains("data/save/") {
println!("Resuming from {}", input);
flame::start("read sim savestate");
let sim: Sim = abstutil::read_json(&input).expect("loading sim state failed");
flame::end("read sim savestate");
// TODO assuming the relative path :(
let map_path = format!("../data/{}.abst", sim.map_name);
let map =
@ -27,7 +30,9 @@ pub fn load(
println!("Loading map {}", input);
let map = Map::new(&input, &edits).expect("Couldn't load map");
let control_map = ControlMap::new(&map);
flame::start("create sim");
let sim = Sim::new(&map, scenario_name, rng_seed, savestate_every);
flame::end("create sim");
(map, edits, control_map, sim)
}
}

View File

@ -9,6 +9,7 @@ extern crate dimensioned;
extern crate ezgui;
#[macro_use]
extern crate failure;
extern crate flame;
extern crate geom;
extern crate graphics;
#[macro_use]