kernel::hil::hw_debug

Trait 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§

Source

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.

Source

fn stop(&self)

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

Source

fn count(&self) -> u64

Return the current value of the cycle counter.

Source

fn reset(&self)

Reset the counter to zero and stop the cycle counter.

Provided Methods§

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§