use haystackfm::alphabet::DnaSequence;
pub const BENCH_SIZES: &[usize] = &[1_000, 10_000, 100_000, 500_000];
pub fn random_dna(len: usize) -> String {
use rand::Rng;
let mut rng = rand::rng();
let bases = ['A', 'C', 'G', 'T'];
(0..len).map(|_| bases[rng.random_range(0..4)]).collect()
}
pub fn random_dna_seq(len: usize) -> DnaSequence {
DnaSequence::from_str(&random_dna(len)).unwrap()
}
pub fn gpu_available() -> bool {
#[cfg(feature = "gpu")]
{
use haystackfm::gpu::GpuContext;
pollster::block_on(GpuContext::new()).is_ok()
}
#[cfg(not(feature = "gpu"))]
false
}
pub fn measure_ms<F: FnMut()>(mut f: F, warmup: usize, iters: usize) -> f64 {
for _ in 0..warmup {
f();
}
let start = std::time::Instant::now();
for _ in 0..iters {
f();
}
start.elapsed().as_secs_f64() * 1000.0 / iters as f64
}