run_test_suite_lib/
trace.rs1#[cfg(target_os = "fuchsia")]
6macro_rules! duration {
7 ($name:expr) => {
8 ::fuchsia_trace::duration!("run_test_suite", $name);
9 };
10}
11
12#[cfg(not(target_os = "fuchsia"))]
14macro_rules! duration {
15 ($name:literal) => {
16 let _scope = crate::trace::DurationScope::new($name);
17 };
18}
19
20#[cfg(not(target_os = "fuchsia"))]
21pub(crate) struct DurationScope {
22 start: std::time::Instant,
23 name: &'static str,
24}
25
26#[cfg(not(target_os = "fuchsia"))]
27impl DurationScope {
28 pub(crate) fn new(name: &'static str) -> Self {
29 Self { name, start: std::time::Instant::now() }
30 }
31}
32
33#[cfg(not(target_os = "fuchsia"))]
34impl std::ops::Drop for DurationScope {
35 fn drop(&mut self) {
36 log::trace!(
37 name = self.name,
38 duration = self.start.elapsed().as_nanos() as u64;
39 "DURATION_NANOS"
40 );
41 }
42}
43
44pub(crate) use duration;