From a469e5c678089e27e7a3d51cf1d7d102c8fe53dd Mon Sep 17 00:00:00 2001 From: desbma-s1n Date: Thu, 30 May 2024 12:12:27 +0200 Subject: [PATCH] refactor: move regex parser specific bench --- src/strace/parser/mod.rs | 26 -------------------------- src/strace/parser/regex.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/strace/parser/mod.rs b/src/strace/parser/mod.rs index dc7a92b..3445c2a 100644 --- a/src/strace/parser/mod.rs +++ b/src/strace/parser/mod.rs @@ -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::>() - .join("") - ); - - b.iter(|| { - parse_buffer(&s).unwrap(); - }); - } -} diff --git a/src/strace/parser/regex.rs b/src/strace/parser/regex.rs index 88dc157..3ab09ad 100644 --- a/src/strace/parser/regex.rs +++ b/src/strace/parser/regex.rs @@ -449,3 +449,29 @@ fn parse_buffer(s: &str) -> anyhow::Result> { .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::>() + .join("") + ); + + b.iter(|| { + parse_buffer(&s).unwrap(); + }); + } +}