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§
Sourcefn available_counters(&self) -> Vec<CounterType>
fn available_counters(&self) -> Vec<CounterType>
Get available counter types on this platform
Sourcefn is_available(&self, countertype: &CounterType) -> bool
fn is_available(&self, countertype: &CounterType) -> bool
Check if a counter type is available
Sourcefn start_counter(&self, countertype: &CounterType) -> CoreResult<()>
fn start_counter(&self, countertype: &CounterType) -> CoreResult<()>
Start monitoring a counter
Sourcefn stop_counter(&self, countertype: &CounterType) -> CoreResult<()>
fn stop_counter(&self, countertype: &CounterType) -> CoreResult<()>
Stop monitoring a counter
Sourcefn read_counter(&self, countertype: &CounterType) -> CoreResult<CounterValue>
fn read_counter(&self, countertype: &CounterType) -> CoreResult<CounterValue>
Read current value of a counter
Sourcefn read_counters(
&self,
countertypes: &[CounterType],
) -> CoreResult<Vec<CounterValue>>
fn read_counters( &self, countertypes: &[CounterType], ) -> CoreResult<Vec<CounterValue>>
Read multiple counters atomically
Sourcefn reset_counter(&self, countertype: &CounterType) -> CoreResult<()>
fn reset_counter(&self, countertype: &CounterType) -> CoreResult<()>
Reset a counter to zero
Sourcefn is_overflowed(&self, countertype: &CounterType) -> CoreResult<bool>
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§
impl PerformanceCounter for LinuxPerfCounter
Available on Linux and crate feature
profiling_perf only.