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"
|
edition = "2018"
|
||||||
name = "rtiow"
|
name = "rtiow"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
harness = false
|
harness = false
|
||||||
name = "spheres"
|
name = "spheres"
|
||||||
@ -11,7 +12,7 @@ name = "spheres"
|
|||||||
actix-web = "0.7.8"
|
actix-web = "0.7.8"
|
||||||
askama = "0.7.1"
|
askama = "0.7.1"
|
||||||
chrono = "*"
|
chrono = "*"
|
||||||
cpuprofiler = "0.0.3"
|
cpuprofiler = { version = "0.0.3", optional = true }
|
||||||
crossbeam-channel = "0.2.4"
|
crossbeam-channel = "0.2.4"
|
||||||
getopts = "*"
|
getopts = "*"
|
||||||
image = "0.19.0"
|
image = "0.19.0"
|
||||||
@ -27,7 +28,7 @@ structopt = "0.2.10"
|
|||||||
|
|
||||||
[dependencies.prometheus]
|
[dependencies.prometheus]
|
||||||
features = ["process", "push"]
|
features = ["process", "push"]
|
||||||
version = "0.5.0"
|
version = "0.7.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.2"
|
criterion = "0.2"
|
||||||
@ -35,3 +36,6 @@ criterion = "0.2"
|
|||||||
[profile]
|
[profile]
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
profile = ["cpuprofiler"]
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
|
#[cfg(feature = "profile")]
|
||||||
extern crate cpuprofiler;
|
extern crate cpuprofiler;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate rtiow;
|
extern crate rtiow;
|
||||||
@ -16,6 +17,7 @@ use std::time::Instant;
|
|||||||
|
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
|
#[cfg(feature = "profile")]
|
||||||
use cpuprofiler::PROFILER;
|
use cpuprofiler::PROFILER;
|
||||||
use prometheus::Encoder;
|
use prometheus::Encoder;
|
||||||
use structopt::StructOpt;
|
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> {
|
fn main() -> Result<(), std::io::Error> {
|
||||||
stderrlog::new()
|
stderrlog::new()
|
||||||
.verbosity(3)
|
.verbosity(3)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user