Trait embedded_profiling::EmbeddedProfiler[][src]

pub trait EmbeddedProfiler {
    fn read_clock(&self) -> EPInstant;

    fn log_snapshot(&self, _snapshot: &EPSnapshot) { ... }
fn at_start(&self) { ... }
fn at_end(&self) { ... }
fn start_snapshot(&self) -> EPInstant { ... }
fn end_snapshot(
        &self,
        start: EPInstant,
        name: &'static str
    ) -> Option<EPSnapshot> { ... } }
Expand description

The main trait to implement. All that is required is a way to read time and a way to output our results, if desired. You can also implement functions that get called when a snapshot starts and ends.

Required methods

Takes a reading from the clock.

Used by the underlying trait methods EmbeddedProfiler::start_snapshot and EmbeddedProfiler::end_snapshot.

Provided methods

Optionally log the snapshot to some output, like a serial port.

Optional function that gets called at the start of the snapshot recording.

If one would want to very simple profiling, they could use at_start and at_end to simply toggle a GPIO.

Optional function that gets called at the end of the snapshot recording.

takes the starting snapshot of a specific trace.

let start_time = my_profiler.start_snapshot();
function_to_profile();
if let Some(snapshot) = my_profiler.end_snapshot(start_time, "function_to_profile") {
    my_profiler.log_snapshot(&snapshot);
}

computes the duration of the snapshot given the start time, if there hasn’t been overflow.

Implementors