Skip to content

Commit d85b72e

Browse files
add hash_kmers_bench
1 parent e946274 commit d85b72e

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ rand = "0.9"
1919

2020
[features]
2121
scalar = ["packed-seq/scalar"]
22+
23+
[profile.release]
24+
lto = true
25+
debug = false

src/test.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,36 @@ fn seeded() {
159159
}
160160
});
161161
}
162+
163+
#[test]
164+
#[ignore = "This is a benchmark, not a test"]
165+
fn hash_kmers_bench() {
166+
eprintln!("\nBench SeqHash::hash_kmers_simd");
167+
168+
for k in [1, 31] {
169+
eprintln!("\nk = {k}");
170+
171+
let hasher = NtHasher::<false>::new(k);
172+
173+
for len in [100, 150, 200, 1000, 1_000_000] {
174+
// 1Gbp input.
175+
let rep = 1_000_000_000 / len;
176+
let seq = PackedSeqVec::random(len);
177+
178+
let start = std::time::Instant::now();
179+
for _ in 0..rep {
180+
let PaddedIt { it, .. } = hasher.hash_kmers_simd(seq.as_slice(), k);
181+
it.for_each(
182+
#[inline(always)]
183+
|y| {
184+
core::hint::black_box(&y);
185+
},
186+
);
187+
}
188+
eprintln!(
189+
"Len {len:>7} => {:.03} Gbp/s",
190+
start.elapsed().as_secs_f64().recip()
191+
);
192+
}
193+
}
194+
}

0 commit comments

Comments
 (0)