Crate ep_dwt[−][src]
Expand description
EmbeddedProfiler
implementation based on DWT
.
This profiler depends on the DWT
hardware which is not available on cortex-M0.
The profiler’s resolution is the same as the core clock. The cycle count clock is
free-running, so overflows are likely if you have long running functions to profile.
To mitigate this, one can use the extended
feature, which extends the resolution of
the counter from u32
to u64
using the DebugMonitor
exception. It is set
to expire just before overflow, so you can expect an exception to fire every 2**32
clock cycles.
Snapshots are logged using log::info!
, so having a logger installed is required
if you want to use embedded_profiling::log_snapshot
or functions that call it
(like embedded_profiling::profile_function
).
Example Usage
let mut core = CorePeripherals::take().unwrap();
// (...)
let dwt_profiler = cortex_m::singleton!(: ep_dwt::DwtProfiler::<CORE_FREQ> =
ep_dwt::DwtProfiler::<CORE_FREQ>::new(&mut core.DCB, core.DWT, CORE_FREQ))
.unwrap();
unsafe {
embedded_profiling::set_profiler(dwt_profiler).unwrap();
}
// (...)
embedded_profiling::profile("print_profile", || println!("Hello, world"));
Features
extended
Extends the DWT
cycle counter’s native resolution from 32 bit to 64 bit using
the cycle compare functionality and the DebugMonitor
exception. The exception will
fire every 2**32 clock cycles. Enables the embedded-profiling
feature container-u64
.
proc-macros
enables the proc-macros
feature in embedded-profiling
. Enables
the embedded_profiling::profile_function
procedural macro.
Structs
DWT trace unit implementing EmbeddedProfiler
.