Make cpu profiling an optional build time configuration.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
932ecf182c
commit
b73444beaf
@ -3,6 +3,7 @@ authors = ["Bill Thiede <rust@xinu.tv>"]
|
||||
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"]
|
||||
|
||||
@ -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<T: Into<Vec<u8>>>(&self, _: T) -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
fn stop(&self) -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
struct MockProfiler;
|
||||
|
||||
impl MockProfiler {
|
||||
fn lock(&self) -> Option<MockTimer> {
|
||||
Some(MockTimer {})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "profile"))]
|
||||
static PROFILER: MockProfiler = MockProfiler {};
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
stderrlog::new()
|
||||
.verbosity(3)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user