mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 10:14:10 +02:00
optimize line splitting
This commit is contained in:
parent
0a110dc0f0
commit
7bd667004b
3 changed files with 52 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use std::fs::read_to_string;
|
||||
use std::time::Duration;
|
||||
use tf_log_parser::{parse, GameEvent, RawEvent};
|
||||
use tf_log_parser::{parse, GameEvent, RawEvent, LineSplit};
|
||||
|
||||
pub fn parse_benchmark(c: &mut Criterion) {
|
||||
let input = read_to_string("test_data/log_2892242.log").unwrap();
|
||||
|
|
@ -26,8 +26,7 @@ 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)
|
||||
.split("L ")
|
||||
LineSplit::new(black_box(&input))
|
||||
.filter(|line| !line.is_empty())
|
||||
.flat_map(RawEvent::parse)
|
||||
.count();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use iai::black_box;
|
||||
use tf_log_parser::{parse, RawEvent};
|
||||
use tf_log_parser::{LineSplit, parse, RawEvent};
|
||||
|
||||
static LOG: &str = include_str!("../test_data/log_2892242.log");
|
||||
|
||||
|
|
@ -9,8 +9,7 @@ pub fn parse_benchmark() {
|
|||
|
||||
pub fn parse_raw() {
|
||||
black_box(
|
||||
black_box(&LOG)
|
||||
.split("L ")
|
||||
LineSplit::new(black_box(&LOG))
|
||||
.filter(|line| !line.is_empty())
|
||||
.flat_map(RawEvent::parse)
|
||||
.count(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue