diff --git a/headless/Cargo.toml b/headless/Cargo.toml index 16ba172392..79c0b676d5 100644 --- a/headless/Cargo.toml +++ b/headless/Cargo.toml @@ -4,9 +4,13 @@ version = "0.1.0" authors = ["Dustin Carlino "] edition = "2018" +[features] +default = [] +profiler = ["cpuprofiler"] + [dependencies] abstutil = { path = "../abstutil" } -cpuprofiler = "0.0.3" +cpuprofiler = { version = "0.0.3", optional = true } geom = { path = "../geom" } map_model = { path = "../map_model" } sim = { path = "../sim" } diff --git a/headless/src/main.rs b/headless/src/main.rs index d7de4db2ab..640c0954cd 100644 --- a/headless/src/main.rs +++ b/headless/src/main.rs @@ -29,11 +29,14 @@ fn main() { timer.done(); if enable_profiler { - cpuprofiler::PROFILER - .lock() - .unwrap() - .start("./profile") - .unwrap(); + #[cfg(feature = "profiler")] + { + cpuprofiler::PROFILER + .lock() + .unwrap() + .start("./profile") + .unwrap(); + } } let timer = Timer::new("run sim until done"); sim.run_until_done( @@ -44,7 +47,10 @@ fn main() { sim.save(); // Some simulations run for a really long time, just do this. if enable_profiler { - cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + #[cfg(feature = "profiler")] + { + cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + } } } if paranoia { @@ -56,6 +62,9 @@ fn main() { timer.done(); println!("Done at {}", sim.time()); if enable_profiler && save_at.is_none() { - cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + #[cfg(feature = "profiler")] + { + cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + } } }