diff --git a/rtiow/Cargo.toml b/rtiow/Cargo.toml index 782b189..4b43c99 100644 --- a/rtiow/Cargo.toml +++ b/rtiow/Cargo.toml @@ -3,6 +3,7 @@ authors = ["Bill Thiede "] edition = "2018" name = "rtiow" version = "0.1.0" + [[bench]] harness = false name = "spheres" @@ -11,7 +12,7 @@ name = "spheres" actix-web = "0.7.8" askama = "0.7.1" chrono = "*" -cpuprofiler = "0.0.3" +cpuprofiler = { version = "0.0.3", optional = true } crossbeam-channel = "0.2.4" getopts = "*" image = "0.19.0" @@ -27,7 +28,7 @@ structopt = "0.2.10" [dependencies.prometheus] features = ["process", "push"] -version = "0.5.0" +version = "0.7.0" [dev-dependencies] criterion = "0.2" @@ -35,3 +36,6 @@ criterion = "0.2" [profile] [profile.release] debug = true + +[features] +profile = ["cpuprofiler"] diff --git a/rtiow/src/bin/tracer.rs b/rtiow/src/bin/tracer.rs index 4612aaf..293b3cb 100644 --- a/rtiow/src/bin/tracer.rs +++ b/rtiow/src/bin/tracer.rs @@ -1,6 +1,7 @@ #[macro_use] extern crate log; extern crate chrono; +#[cfg(feature = "profile")] extern crate cpuprofiler; extern crate rand; extern crate rtiow; @@ -16,6 +17,7 @@ use std::time::Instant; use chrono::DateTime; use chrono::Utc; +#[cfg(feature = "profile")] use cpuprofiler::PROFILER; use prometheus::Encoder; use structopt::StructOpt; @@ -62,6 +64,28 @@ fn push_metrics(push_gateway_addr: &str, instance: String, start_time: &DateTime } } +struct MockTimer; + +impl MockTimer { + fn start>>(&self, _: T) -> Result<(), ()> { + Ok(()) + } + fn stop(&self) -> Result<(), ()> { + Ok(()) + } +} + +struct MockProfiler; + +impl MockProfiler { + fn lock(&self) -> Option { + Some(MockTimer {}) + } +} + +#[cfg(not(feature = "profile"))] +static PROFILER: MockProfiler = MockProfiler {}; + fn main() -> Result<(), std::io::Error> { stderrlog::new() .verbosity(3)