Skip to main content

perf_scope

Macro perf_scope 

Source
macro_rules! perf_scope {
    ($name:ident) => { ... };
}
Expand description

Declares a named timer for the enclosing scope.

fn foo() {
    perf_scope!(total);

    do_something();

    profile_log!(
        target: "perf",
        log::Level::Info,
        "foo: {:?}",
        total.elapsed(),
    );
}

Expands to nothing when the profile feature is disabled, so every use of the declared binding must live inside a [macro@profile_log!] invocation (or its own #[cfg(any(feature = "profile", debug_assertions))] gate).