woops, headless crate didnt have the fix to toggle off cpuprofiler by default

This commit is contained in:
Dustin Carlino 2019-10-04 11:21:55 -07:00
parent 0d27a11b2b
commit a45b393b0d
2 changed files with 21 additions and 8 deletions

View File

@ -4,9 +4,13 @@ version = "0.1.0"
authors = ["Dustin Carlino <dabreegster@gmail.com>"] authors = ["Dustin Carlino <dabreegster@gmail.com>"]
edition = "2018" edition = "2018"
[features]
default = []
profiler = ["cpuprofiler"]
[dependencies] [dependencies]
abstutil = { path = "../abstutil" } abstutil = { path = "../abstutil" }
cpuprofiler = "0.0.3" cpuprofiler = { version = "0.0.3", optional = true }
geom = { path = "../geom" } geom = { path = "../geom" }
map_model = { path = "../map_model" } map_model = { path = "../map_model" }
sim = { path = "../sim" } sim = { path = "../sim" }

View File

@ -29,11 +29,14 @@ fn main() {
timer.done(); timer.done();
if enable_profiler { if enable_profiler {
cpuprofiler::PROFILER #[cfg(feature = "profiler")]
.lock() {
.unwrap() cpuprofiler::PROFILER
.start("./profile") .lock()
.unwrap(); .unwrap()
.start("./profile")
.unwrap();
}
} }
let timer = Timer::new("run sim until done"); let timer = Timer::new("run sim until done");
sim.run_until_done( sim.run_until_done(
@ -44,7 +47,10 @@ fn main() {
sim.save(); sim.save();
// Some simulations run for a really long time, just do this. // Some simulations run for a really long time, just do this.
if enable_profiler { if enable_profiler {
cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); #[cfg(feature = "profiler")]
{
cpuprofiler::PROFILER.lock().unwrap().stop().unwrap();
}
} }
} }
if paranoia { if paranoia {
@ -56,6 +62,9 @@ fn main() {
timer.done(); timer.done();
println!("Done at {}", sim.time()); println!("Done at {}", sim.time());
if enable_profiler && save_at.is_none() { if enable_profiler && save_at.is_none() {
cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); #[cfg(feature = "profiler")]
{
cpuprofiler::PROFILER.lock().unwrap().stop().unwrap();
}
} }
} }