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 criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use std::fs::read_to_string;
|
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) {
|
pub fn parse_benchmark(c: &mut Criterion) {
|
||||||
let input = read_to_string("test_data/log_2892242.log").unwrap();
|
let input = read_to_string("test_data/log_2892242.log").unwrap();
|
||||||
c.bench_function("parse 2892242", |b| b.iter(|| parse(black_box(&input))));
|
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);
|
criterion_main!(benches);
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,12 @@ impl EventHandler for MedicStatsHandler {
|
||||||
GameEvent::MedicDeath(death) => {
|
GameEvent::MedicDeath(death) => {
|
||||||
let builder = self.0.entry(SteamId3(healer_steam_id)).or_default();
|
let builder = self.0.entry(SteamId3(healer_steam_id)).or_default();
|
||||||
let charge = death.charge.unwrap_or_default();
|
let charge = death.charge.unwrap_or_default();
|
||||||
if charge > 95 && charge < 100 {
|
if charge >= 95 && charge < 100 {
|
||||||
builder.near_full_charge_death += 1;
|
builder.near_full_charge_death += 1;
|
||||||
} else if charge >= 100 {
|
} else if charge >= 100 {
|
||||||
builder.drops += 1;
|
builder.drops += 1;
|
||||||
}
|
}
|
||||||
if time - builder.last_uber_end <= 20 {
|
if time - builder.last_uber_end <= 10 {
|
||||||
builder.deaths_after_uber += 1;
|
builder.deaths_after_uber += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue