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

#601 in Hardware support

Download history 265/week @ 2023-12-13 352/week @ 2023-12-20 241/week @ 2023-12-27 603/week @ 2024-01-03 1334/week @ 2024-01-10 1417/week @ 2024-01-17 1194/week @ 2024-01-24 1511/week @ 2024-01-31 1629/week @ 2024-02-07 1145/week @ 2024-02-14 1361/week @ 2024-02-21 1418/week @ 2024-02-28 979/week @ 2024-03-06 951/week @ 2024-03-13 908/week @ 2024-03-20 728/week @ 2024-03-27

3,840 downloads per month
Used in 10 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
~46K SLoC