bin+lib perfcnt

Library to configure and read hardware performance counters in rust

19 releases

0.8.0 Mar 3, 2022
0.7.1 Apr 7, 2021
0.7.0 Feb 27, 2021
0.6.0 Jun 18, 2020
0.0.2 Nov 29, 2015
Download history 577/week @ 2024-06-19 607/week @ 2024-06-26 396/week @ 2024-07-03 512/week @ 2024-07-10 829/week @ 2024-07-17 791/week @ 2024-07-24 872/week @ 2024-07-31 949/week @ 2024-08-07 911/week @ 2024-08-14 533/week @ 2024-08-21 1324/week @ 2024-08-28 867/week @ 2024-09-04 963/week @ 2024-09-11 828/week @ 2024-09-18 1415/week @ 2024-09-25 1494/week @ 2024-10-02

4,874 downloads per month
Used in 8 crates

MIT license

115KB
2.5K SLoC

perfcnt Build Status Crates.io

A library to program performance counters in rust.

Documentation

Provided Programs

  • perfcnt-list: Lists all architecture specific events available on the current machine (currently only supports Intel x86).

Known limitations

  • Linux support without breakpoints and tracepoints
  • No Windows or MacOS X support
  • Missing raw AMD and ARM aarch64 events

lib.rs:

Example usage:

use perfcnt::{AbstractPerfCounter, PerfCounter};
use perfcnt::linux::{PerfCounterBuilderLinux, HardwareEventType};

let mut pc: PerfCounter =
    PerfCounterBuilderLinux::from_hardware_event(HardwareEventType::CacheMisses)
        .finish().expect("Could not create the counter");
pc.start().expect("Can not start the counter");
pc.stop().expect("Can not start the counter");
let res = pc.read().expect("Can not read the counter");
println!("Measured {} cache misses.", res);

Dependencies

~4.5MB
~50K SLoC