2 个不稳定版本
0.2.0 | 2024 年 8 月 8 日 |
---|---|
0.1.0 | 2024 年 8 月 8 日 |
#5 在 #perf-event
每月下载 203 次
14KB
285 行
此库仅用于读取 CPU 指令,不是完整的 perf_event_open 包
权限要求 ⚠ : 确保程序具有 ROOT 权限
lib.rs
:
此库仅用于读取 CpuInstructionNumber
特化,不是完整的 perf_event_read 包
示例
use std::{fs, time::{Duration, Instant}, thread};
use cpu_instructions_reader::{InstructionNumber, InstructionNumberReader, InstructionNumberInstant};
let reader = InstructionNumberReader::new().unwrap();
let record_1 = reader.instant(0).unwrap();
thread::sleep(Duration::from_secs(1));
let record_2 = reader.instant(0).unwrap();
let instructions = record_2 - record_1;
println!("{instructions}");
依赖项
~0.4–1.1MB
~25K SLoC