diff --git a/editor/src/abtest/setup.rs b/editor/src/abtest/setup.rs index 0014d8a60a..b2e8f35f14 100644 --- a/editor/src/abtest/setup.rs +++ b/editor/src/abtest/setup.rs @@ -88,45 +88,56 @@ fn pick_ab_test(map: &Map, mut wizard: WrappedWizard) -> Option { } fn launch_test(test: &ABTest, ui: &mut UI, ctx: &mut EventCtx) -> Mode { - println!("Launching A/B test {}...", test.test_name); - let load = PathBuf::from(format!( - "../data/scenarios/{}/{}", - test.map_name, test.scenario_name - )); - let current_flags = &ui.primary.current_flags; - let rng_seed = if current_flags.sim_flags.rng_seed.is_some() { - current_flags.sim_flags.rng_seed - } else { - Some(42) - }; + let (primary, secondary) = ctx.loading_screen( + &format!("Launching A/B test {}", test.test_name), + |ctx, mut timer| { + let load = PathBuf::from(format!( + "../data/scenarios/{}/{}", + test.map_name, test.scenario_name + )); + let current_flags = &ui.primary.current_flags; + let rng_seed = if current_flags.sim_flags.rng_seed.is_some() { + current_flags.sim_flags.rng_seed + } else { + Some(42) + }; - // TODO Cheaper to load the edits for the map and then instantiate the scenario for the - // primary. - let primary = PerMapUI::new( - Flags { - sim_flags: SimFlags { - load: load.clone(), - rng_seed, - run_name: Some(format!("{} with {}", test.test_name, test.edits1_name)), - edits_name: test.edits1_name.clone(), - }, - ..current_flags.clone() + // TODO Cheaper to load the edits for the map and then instantiate the scenario for the + // primary. + timer.start("load primary"); + let primary = PerMapUI::new( + Flags { + sim_flags: SimFlags { + load: load.clone(), + rng_seed, + run_name: Some(format!("{} with {}", test.test_name, test.edits1_name)), + edits_name: test.edits1_name.clone(), + }, + ..current_flags.clone() + }, + &ui.cs, + ctx, + &mut timer, + ); + timer.stop("load primary"); + timer.start("load secondary"); + let secondary = PerMapUI::new( + Flags { + sim_flags: SimFlags { + load, + rng_seed, + run_name: Some(format!("{} with {}", test.test_name, test.edits2_name)), + edits_name: test.edits2_name.clone(), + }, + ..current_flags.clone() + }, + &ui.cs, + ctx, + &mut timer, + ); + timer.stop("load secondary"); + (primary, secondary) }, - &ui.cs, - ctx, - ); - let secondary = PerMapUI::new( - Flags { - sim_flags: SimFlags { - load, - rng_seed, - run_name: Some(format!("{} with {}", test.test_name, test.edits2_name)), - edits_name: test.edits2_name.clone(), - }, - ..current_flags.clone() - }, - &ui.cs, - ctx, ); ui.primary = primary; diff --git a/editor/src/ui.rs b/editor/src/ui.rs index 54b779ab4d..e79ccf8d10 100644 --- a/editor/src/ui.rs +++ b/editor/src/ui.rs @@ -4,7 +4,7 @@ use crate::render::{ MIN_ZOOM_FOR_DETAIL, }; use abstutil; -use abstutil::MeasureMemory; +use abstutil::{MeasureMemory, Timer}; use ezgui::{Color, EventCtx, GeomBatch, GfxCtx, Prerender}; use geom::{Bounds, Circle, Distance, Duration}; use map_model::{Map, Traversable}; @@ -21,10 +21,10 @@ pub struct UI { impl UI { pub fn new(flags: Flags, ctx: &mut EventCtx) -> UI { let cs = ColorScheme::load().unwrap(); - UI { - primary: PerMapUI::new(flags, &cs, ctx), - cs, - } + let primary = ctx.loading_screen("load map", |ctx, mut timer| { + PerMapUI::new(flags, &cs, ctx, &mut timer) + }); + UI { primary, cs } } pub fn draw( @@ -407,19 +407,15 @@ pub struct PerMapUI { } impl PerMapUI { - pub fn new(flags: Flags, cs: &ColorScheme, ctx: &mut EventCtx) -> PerMapUI { - let (map, sim, draw_map) = ctx.loading_screen("load map", |ctx, timer| { - let mut mem = MeasureMemory::new(); - let (map, sim, _) = flags.sim_flags.load(Some(Duration::minutes(30)), timer); - mem.reset("Map and Sim", timer); + pub fn new(flags: Flags, cs: &ColorScheme, ctx: &mut EventCtx, timer: &mut Timer) -> PerMapUI { + let mut mem = MeasureMemory::new(); + let (map, sim, _) = flags.sim_flags.load(Some(Duration::minutes(30)), timer); + mem.reset("Map and Sim", timer); - timer.start("draw_map"); - let draw_map = DrawMap::new(&map, &flags, cs, ctx.prerender, timer); - timer.stop("draw_map"); - mem.reset("DrawMap", timer); - - (map, sim, draw_map) - }); + timer.start("draw_map"); + let draw_map = DrawMap::new(&map, &flags, cs, ctx.prerender, timer); + timer.stop("draw_map"); + mem.reset("DrawMap", timer); PerMapUI { map, diff --git a/sim/src/sim.rs b/sim/src/sim.rs index 247c8a938b..dd0433a9fc 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -214,10 +214,6 @@ impl Sim { ) { self.trips.agent_starting_trip_leg(AgentID::Car(id), trip); self.transit.bus_created(id, route.id, next_stop_idx); - timer.note(format!( - "Spawned bus {} for route {} ({})", - id, route.name, route.id - )); results.push(id); } else { timer.warn(format!(