From 43c565fd3f7e5aa656f2a919ed45b7d4a0d146c9 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 8 Jan 2020 23:32:22 +1300 Subject: [PATCH] Allow compiling with no_metrics feature (#2) --- Cargo.toml | 3 +++ src/histogram.rs | 2 ++ src/io_uring/mod.rs | 1 + src/metrics.rs | 1 + 4 files changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index cb8a0c5..c63a93c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,6 @@ readme = "README.md" [dependencies] libc = "0.2.66" + +[features] +no_metrics = [] diff --git a/src/histogram.rs b/src/histogram.rs index 4f7b80b..d83a621 100644 --- a/src/histogram.rs +++ b/src/histogram.rs @@ -106,6 +106,8 @@ impl Histogram { .fetch_add(1, Ordering::Relaxed) + 1 } + #[cfg(feature = "no_metrics")] + 0 } /// Retrieve a percentile [0-100]. Returns NAN if no metrics have been diff --git a/src/io_uring/mod.rs b/src/io_uring/mod.rs index 7d8251c..f4bceda 100644 --- a/src/io_uring/mod.rs +++ b/src/io_uring/mod.rs @@ -176,6 +176,7 @@ impl Drop for Uring { } if self.config.print_profile_on_drop { + #[cfg(not(feature = "no_metrics"))] M.print_profile(); } } diff --git a/src/metrics.rs b/src/metrics.rs index b9852cb..6f8e0a7 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -106,6 +106,7 @@ pub struct Metrics { impl Drop for Metrics { fn drop(&mut self) { + #[cfg(not(feature = "no_metrics"))] self.print_profile() } }