Files
alkane-os/tests/bench.rs
T
noah 3ab9d1a4bf
main-release-gate / verify-and-release (push) Failing after 4s
next-build / build (push) Successful in 4s
Initialize Alkane OS target matrix and release gates
2026-10-13 11:13:39 -06:00

33 lines
844 B
Rust

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));
});
}