2020-03-27 20:39:22 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2020-06-26 21:41:37 +00:00
|
|
|
static LINES: &str = include_str!("../tests/fixtures/lineproto/prometheus.lp");
|
2020-03-27 20:39:22 +00:00
|
|
|
|
|
|
|
fn line_parser(c: &mut Criterion) {
|
2020-06-18 00:01:17 +00:00
|
|
|
let mut group = c.benchmark_group("line_parser");
|
2020-03-27 20:39:22 +00:00
|
|
|
|
|
|
|
// group.throughput(Throughput::Elements(LINES.lines().count() as u64));
|
|
|
|
group.throughput(Throughput::Bytes(LINES.len() as u64));
|
|
|
|
group.measurement_time(Duration::from_secs(30));
|
|
|
|
|
|
|
|
group.bench_function("all lines", |b| {
|
|
|
|
b.iter(|| {
|
|
|
|
let lines = delorean::line_parser::parse(LINES).unwrap();
|
|
|
|
assert_eq!(582, lines.len());
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
group.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, line_parser);
|
|
|
|
|
|
|
|
criterion_main!(benches);
|