Skip to main content

PerformanceCounter

Trait PerformanceCounter 

Source
pub trait PerformanceCounter: Send + Sync {
    // Required methods
    fn available_counters(&self) -> Vec<CounterType>;
    fn is_available(&self, countertype: &CounterType) -> bool;
    fn start_counter(&self, countertype: &CounterType) -> CoreResult<()>;
    fn stop_counter(&self, countertype: &CounterType) -> CoreResult<()>;
    fn read_counter(
        &self,
        countertype: &CounterType,
    ) -> CoreResult<CounterValue>;
    fn read_counters(
        &self,
        countertypes: &[CounterType],
    ) -> CoreResult<Vec<CounterValue>>;
    fn reset_counter(&self, countertype: &CounterType) -> CoreResult<()>;
    fn is_overflowed(&self, countertype: &CounterType) -> CoreResult<bool>;
}
Expand description

Hardware performance counter interface

Required Methods§

Source

fn available_counters(&self) -> Vec<CounterType>

Get available counter types on this platform

Source

fn is_available(&self, countertype: &CounterType) -> bool

Check if a counter type is available

Source

fn start_counter(&self, countertype: &CounterType) -> CoreResult<()>

Start monitoring a counter

Source

fn stop_counter(&self, countertype: &CounterType) -> CoreResult<()>

Stop monitoring a counter

Source

fn read_counter(&self, countertype: &CounterType) -> CoreResult<CounterValue>

Read current value of a counter

Source

fn read_counters( &self, countertypes: &[CounterType], ) -> CoreResult<Vec<CounterValue>>

Read multiple counters atomically

Source

fn reset_counter(&self, countertype: &CounterType) -> CoreResult<()>

Reset a counter to zero

Source

fn is_overflowed(&self, countertype: &CounterType) -> CoreResult<bool>

Get counter overflow status

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl PerformanceCounter for LinuxPerfCounter

Available on Linux and crate feature profiling_perf only.
Source§

impl PerformanceCounter for NoOpCounter