| 1 |
use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
| 2 |
use procfs::CpuInfo; |
| 3 |
|
| 4 |
fn bench_cpuinfo(c: &mut Criterion) { |
| 5 |
c.bench_function("CpuInfo::new", |b| b.iter(|| black_box(CpuInfo::new().unwrap()))); |
| 6 |
|
| 7 |
let cpuinfo = black_box(CpuInfo::new().unwrap()); |
| 8 |
c.bench_function("CpuInfo::get_info", |b| b.iter(|| black_box(cpuinfo.get_info(0)))); |
| 9 |
c.bench_function("CpuInfo::model_name", |b| b.iter(|| cpuinfo.model_name(0))); |
| 10 |
c.bench_function("CpuInfo::vendor_id", |b| b.iter(|| cpuinfo.vendor_id(0))); |
| 11 |
c.bench_function("CpuInfo::physical_id", |b| b.iter(|| cpuinfo.physical_id(0))); |
| 12 |
c.bench_function("CpuInfo::flags", |b| b.iter(|| cpuinfo.flags(0))); |
| 13 |
} |
| 14 |
|
| 15 |
criterion_group!(benches, bench_cpuinfo); |
| 16 |
criterion_main!(benches); |