asm_probe_string/asm_probe_string.rs
1//! Instruction-level probe for the string hot kernel (driven by `make asm-diff`).
2//!
3//! `probe_str_eq_scan` is the shape of the elementwise string compare / filter loop:
4//! one `StrBuffer::iter` walk with a per-cell equality. `make asm-diff` holds its
5//! instruction count from rising — the per-element string cost must not regress.
6use std::hint::black_box;
7use volas_core::StrBuffer;
8
9#[inline(never)]
10#[no_mangle]
11pub fn probe_str_eq_scan(s: &StrBuffer, target: &str) -> usize {
12 s.iter().filter(|&x| x == target).count()
13}
14
15fn main() {
16 let sb = StrBuffer::from_vec(vec!["ab".into(), "cd".into(), "ef".into()]);
17 println!("{}", probe_str_eq_scan(black_box(&sb), black_box("cd")));
18}