Stub push/pop

This commit is contained in:
Daniel Lubarov 2022-08-06 22:18:53 -04:00
parent 8ad0924bbb
commit 1e5383c63d

View File

@ -99,6 +99,9 @@ impl TimingTree {
})
}
#[cfg(not(feature = "timing"))]
pub fn push(&mut self, _ctx: &str, _level: log::Level) {}
/// Close the deepest open scope from this tree.
#[cfg(feature = "timing")]
pub fn pop(&mut self) {
@ -114,6 +117,9 @@ impl TimingTree {
self.exit_time = Some(Instant::now());
}
#[cfg(not(feature = "timing"))]
pub fn pop(&mut self) {}
#[cfg(feature = "timing")]
fn duration(&self) -> Duration {
self.exit_time
@ -171,26 +177,16 @@ impl TimingTree {
#[macro_export]
macro_rules! timed {
($timing_tree:expr, $level:expr, $ctx:expr, $exp:expr) => {{
#[cfg(feature = "timing")]
$timing_tree.push($ctx, $level);
let res = $exp;
#[cfg(feature = "timing")]
$timing_tree.pop();
res
}};
// If no context is specified, default to Debug.
($timing_tree:expr, $ctx:expr, $exp:expr) => {{
#[cfg(feature = "timing")]
$timing_tree.push($ctx, log::Level::Debug);
let res = $exp;
#[cfg(feature = "timing")]
$timing_tree.pop();
res
}};
}