set_profiler

Function set_profiler 

Source
pub unsafe fn set_profiler(
    profiler: &'static dyn EmbeddedProfiler,
) -> Result<(), SetProfilerError>
Expand description

Sets the global profiler.

§Safety

Must be completed with no other threads running or, in an embedded single core environment, with interrupts disabled.

§Errors

returns Err(SetProfilerError) when a global profiler has already been configured

let noop_profiler_ref = embedded_profiling::profiler();  // no-op profiler returned because we haven't set one yet
// interrupts should be disabled while this is called with something like `cortex_m::interrupt::free`
unsafe {
    embedded_profiling::set_profiler(&MY_PROFILER).unwrap();
}
let my_profiler_ref = embedded_profiling::profiler();  // our profiler now returned