1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use std::error::Error;
use std::path::Path;

pub mod internal {
    use std::marker::PhantomData;
    // See also 6cb371a0-d6f0-48be-87d2-8d824b82e0e7
    struct Unsend(PhantomData<*const ()>);
    impl Unsend {
        #[inline(always)]
        fn new() -> Self {
            Self(PhantomData)
        }
    }
    unsafe impl Sync for Unsend {}
    pub struct SpanGuard(Unsend);
    impl SpanGuard {
        #[inline(always)]
        pub fn new() -> Self {
            Self(Unsend::new())
        }
    }

    // Ensure that SpanGuard implements the same traits as the enabled version
    impl Drop for SpanGuard {
        #[inline(always)]
        fn drop(&mut self) {}
    }
}

#[macro_export]
macro_rules! profile_fn {
    ($($t:tt)*) => {};
}

#[macro_export]
macro_rules! profile_method {
    ($($t:tt)*) => {};
}

#[macro_export]
macro_rules! profile_section {
    ($name:ident) => {
        #[allow(unused_variables)]
        let $name = $crate::internal::SpanGuard::new();
    };
}

#[inline(always)]
pub fn clear() {}

pub fn save<P: AsRef<Path>>(_path: P) -> Result<(), Box<dyn Error>> {
    Err("Firestorm not enabled")?
}

/// Returns whether or not firestorm is enabled
#[inline(always)]
pub const fn enabled() -> bool {
    false
}

pub fn bench<F: Fn(), P: AsRef<Path>>(_path: P, _f: F) -> Result<(), Box<dyn Error>> {
    Err("Firestorm not enabled")?
}