use alkane_os::{power_decision, target_matrix}; use std::hint::black_box; use std::time::Instant; fn measure(name: &str, iterations: u64, mut f: impl FnMut()) { let started = Instant::now(); for _ in 0..iterations { f(); } let ns = started.elapsed().as_nanos() as f64 / iterations as f64; println!("BENCH {name} {ns:.3} ns/op"); } #[test] #[ignore = "microbenchmark"] fn bench_target_matrix() { measure("target_matrix", 20_000, || { black_box( target_matrix() .filter(|target| black_box(target.chip.algorithm) == alkane_os::Algorithm::Sha256) .count(), ); }); } #[test] #[ignore = "microbenchmark"] fn bench_power_policy() { measure("power_policy", 100_000, || { black_box(power_decision(black_box(Some(64_000)), 80_000)); }); }