#performance #counter #events #perf #pmu

bin+lib perfcnt

Library to configure and read hardware performance counters in rust

12 releases

✓ Uses Rust 2018 edition

0.4.4 Apr 19, 2019
0.4.2 Feb 27, 2019
0.4.0 Sep 28, 2018
0.3.0 Sep 8, 2016
0.0.2 Nov 29, 2015

#39 in Hardware support

Download history 15/week @ 2019-01-04 3/week @ 2019-01-11 1/week @ 2019-01-18 12/week @ 2019-01-25 1/week @ 2019-02-01 2/week @ 2019-02-15 33/week @ 2019-02-22 26/week @ 2019-03-01 6/week @ 2019-03-08 4/week @ 2019-03-15 96/week @ 2019-03-22 1/week @ 2019-03-29 13/week @ 2019-04-05 42/week @ 2019-04-12

81 downloads per month
Used in 2 crates

MIT license

110KB
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
~43K SLoC