mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
raw bench
This commit is contained in:
parent
5f2154967b
commit
cba5236496
2 changed files with 21 additions and 4 deletions
|
|
@ -1,11 +1,28 @@
|
|||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use std::fs::read_to_string;
|
||||
use tf_log_parser::parse;
|
||||
use std::time::Duration;
|
||||
use tf_log_parser::{parse, RawEvent};
|
||||
|
||||
pub fn parse_benchmark(c: &mut Criterion) {
|
||||
let input = read_to_string("test_data/log_2892242.log").unwrap();
|
||||
c.bench_function("parse 2892242", |b| b.iter(|| parse(black_box(&input))));
|
||||
}
|
||||
|
||||
criterion_group!(benches, parse_benchmark);
|
||||
pub fn parse_raw(c: &mut Criterion) {
|
||||
let input = read_to_string("test_data/log_2892242.log").unwrap();
|
||||
c.bench_function("parse raw 2892242", |b| {
|
||||
b.iter(|| {
|
||||
black_box(&input)
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("L "))
|
||||
.flat_map(RawEvent::parse)
|
||||
.count();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(
|
||||
name = benches;
|
||||
config = Criterion::default().measurement_time(Duration::from_secs(10));
|
||||
targets = parse_benchmark, parse_raw);
|
||||
criterion_main!(benches);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue