Skip to content

Commit

Permalink
perf: add parse_line bench
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma-s1n committed Jun 3, 2024
1 parent 76f3c14 commit c57daee
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/strace/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,3 +1730,33 @@ mod tests {
);
}
}

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

use std::io::BufReader;

use super::*;

use test::Bencher;

#[bench]
fn bench_parse_line(b: &mut Bencher) {
let log_path = Path::new("strace.log");
if !log_path.is_file() {
return;
}
let log_lines: Vec<_> = BufReader::new(File::open(log_path).unwrap())
.lines()
.take(1000)
.collect::<Result<_, _>>()
.unwrap();

b.iter(|| {
for log_line in &log_lines {
let _ = parse_line(&log_line, &[]);
}
});
}
}

0 comments on commit c57daee

Please sign in to comment.