mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 12:50:49 +01:00
35 lines
878 B
Rust
35 lines
878 B
Rust
use gungraun::prelude::*;
|
|
use std::convert::TryFrom;
|
|
use std::hint::black_box;
|
|
use tf_log_parser::raw_event::RawSubject;
|
|
use tf_log_parser::{parse, LineSplit, RawEvent, SubjectId};
|
|
|
|
static LOG: &str = include_str!("../tests/data/log_2892242.log");
|
|
|
|
#[library_benchmark]
|
|
fn parse_benchmark() {
|
|
black_box(parse(black_box(LOG))).ok();
|
|
}
|
|
|
|
#[library_benchmark]
|
|
fn parse_raw() {
|
|
black_box(
|
|
LineSplit::new(black_box(LOG))
|
|
.filter(|line| !line.is_empty())
|
|
.flat_map(RawEvent::parse)
|
|
.count(),
|
|
);
|
|
}
|
|
|
|
#[library_benchmark]
|
|
fn subject_id() {
|
|
let raw = black_box(RawSubject::Player("Kumis<10><[U:1:169048576]><Blue>"));
|
|
black_box(SubjectId::try_from(&raw).unwrap());
|
|
}
|
|
|
|
library_benchmark_group!(
|
|
name = bench_parse;
|
|
benchmarks = parse_raw, parse_benchmark, subject_id
|
|
);
|
|
|
|
main!(library_benchmark_groups = bench_parse);
|