Trait kernel::hil::hw_debug::CycleCounter

source ·
pub trait CycleCounter {
    // Required methods
    fn start(&self);
    fn stop(&self);
    fn count(&self) -> u64;
    fn reset(&self);

    // Provided method
    fn profile_closure<F: FnOnce()>(&self, f: F) -> u64 { ... }

Required Methods§


fn start(&self)

Enable and start the cycle counter. Depending on the underlying hardware, it may be necessary to call reset before starting the cycle counter for the first time to get accurate results.


fn stop(&self)

Stop the cycle counter. Does nothing if the cycle counter is not present.


fn count(&self) -> u64

Return the current value of the cycle counter.


fn reset(&self)

Reset the counter to zero and stop the cycle counter.

Provided Methods§


fn profile_closure<F: FnOnce()>(&self, f: F) -> u64

Benchmark the number of cycles to run a passed closure. This function is intended for use debugging in-kernel routines.

Object Safety§

This trait is not object safe.