Trait embedded_profiling::EmbeddedProfiler [−][src]
pub trait EmbeddedProfiler {
fn read_clock(&self) -> EPInstant;
fn reset_clock(&mut self) { ... }
fn log_snapshot(&self, _snapshot: &EPSnapshot) { ... }
fn at_start(&self) { ... }
fn at_end(&self) { ... }
fn start_snapshot(&mut self) -> EPInstant { ... }
fn end_snapshot(&self, start: EPInstant, name: &'static str) -> 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
fn read_clock(&self) -> EPInstant
fn read_clock(&self) -> EPInstant
Takes a reading from the clock
Provided methods
fn reset_clock(&mut self)
fn reset_clock(&mut self)
Optionally reset the clock to zero. This function will be called at the beginning of
start_snapshot.
TODO: not sure if this API is worth while or not.
fn log_snapshot(&self, _snapshot: &EPSnapshot)
fn log_snapshot(&self, _snapshot: &EPSnapshot)
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.
fn start_snapshot(&mut self) -> EPInstant
fn start_snapshot(&mut self) -> EPInstant
takes the starting snapshot of a specific trace
fn end_snapshot(&self, start: EPInstant, name: &'static str) -> EPSnapshot
fn end_snapshot(&self, start: EPInstant, name: &'static str) -> EPSnapshot
computes the duration of the snapshot given the start time