#cycle #cpu #linux #perf-event #ffi-bind

cpu_cycles_reader

perf_event_read package specialized for reading cpu cycles

20 releases (2 stable)

1.0.1 Feb 9, 2024
0.2.0 Jan 14, 2024
0.1.41 Jul 23, 2023

#5 in #perf-event

Download history 3/week @ 2024-02-03 21/week @ 2024-02-10 61/week @ 2024-02-17 44/week @ 2024-02-24 22/week @ 2024-03-02 22/week @ 2024-03-09 13/week @ 2024-03-16 4/week @ 2024-03-23 86/week @ 2024-03-30 22/week @ 2024-04-06 3/week @ 2024-04-13 18/week @ 2024-04-20

130 downloads per month

WTFPL license

15KB
322 lines

This is only specialized for reading CpuCycles, not a complete package of perf_event_read

Permission requirements ⚠ : Make sure the program has ROOT permissions


lib.rs:

This is only for reading CpuCycles specialization, not a complete package of perf_event_read

Example:

use std::{fs, time::{Duration, Instant}, thread};
use cpu_cycles_reader::{Cycles, CyclesReader, CyclesInstant};

let reader = CyclesReader::new().unwrap();
let record_1 = reader.instant(0).unwrap();

thread::sleep(Duration::from_secs(1));

let record_2 = reader.instant(0).unwrap();
let cycles = record_2 - record_1;

println!("{cycles}");

Dependencies

~1.2–1.7MB
~40K SLoC