Skip to content

Commit

Permalink
refactor: move regex parser specific bench
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma-s1n committed May 30, 2024
1 parent c258b51 commit a469e5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/strace/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,29 +1552,3 @@ mod tests {
);
}
}

#[cfg(all(feature = "nightly", test))]
mod benchs {
extern crate test;

use super::*;

use std::iter;

use test::Bencher;

#[bench]
fn bench_parse_buffer(b: &mut Bencher) {
let s = format!(
"\"{}\"",
iter::repeat_with(|| format!("\\x{:02x}", fastrand::u8(..)))
.take(512)
.collect::<Vec<_>>()
.join("")
);

b.iter(|| {
parse_buffer(&s).unwrap();
});
}
}
26 changes: 26 additions & 0 deletions src/strace/parser/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,29 @@ fn parse_buffer(s: &str) -> anyhow::Result<Vec<u8>> {
.into_owned();
Ok(buf)
}

#[cfg(all(feature = "nightly", test))]
mod benchs {
extern crate test;

use super::*;

use std::iter;

use test::Bencher;

#[bench]
fn bench_parse_buffer(b: &mut Bencher) {
let s = format!(
"\"{}\"",
iter::repeat_with(|| format!("\\x{:02x}", fastrand::u8(..)))
.take(512)
.collect::<Vec<_>>()
.join("")
);

b.iter(|| {
parse_buffer(&s).unwrap();
});
}
}

0 comments on commit a469e5c

Please sign in to comment.