Crate ep_systick
source · [−]Expand description
EmbeddedProfiler
implementation based on systick
.
This profiler depends on the SYST
hardware common to most cortex-M devices.
The profiler’s configured 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 24 bit to u32
or u64
using the SysTick
exception. It is set
to expire just before overflow, so you can expect an exception to fire every 2**24
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_systick::SysTickProfiler::<CORE_FREQ> =
ep_systick::SysTickProfiler::<CORE_FREQ>::new(core.SYST, CORE_FREQ))
.unwrap();
unsafe {
embedded_profiling::set_profiler(dwt_profiler).unwrap();
}
// (...)
embedded_profiling::profile("print_profile", || println!("Hello, world"));
Features
extended
as discussed above, extend the native resolution of 24 bits to either 32 or 64 bits
using the SysTick
exception. The exception fires ever 2**24 clock cycles.
container-u64
enables the container-u64
feature in embedded-profiling
. Use
a u64
as the time storage type instead of u32
for longer running profiling.
proc-macros
enables the proc-macros
feature in embedded-profiling
. Enables
the embedded_profiling::profile_function
procedural macro.
Structs
systick
implementation of EmbeddedProfiler
.