aboutsummaryrefslogtreecommitdiff
path: root/benches/parse.rs
blob: f7b7412b7eb851bba8ca01771feaac2a727138f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use criterion::*;
use std::fs::read_to_string;
use std::hint::black_box;

use wmap_parser::*;

fn bench(c: &mut Criterion) {
    let mut group = c.benchmark_group("Parsing");
    let example_source = read_to_string("doc/example.wmap").unwrap();
    let huge_source = read_to_string("doc/huge.wmap").unwrap();

    group.sample_size(500);
    group.bench_function("parse example", |b| {
        b.iter(|| parse(black_box(&example_source)))
    });
    group.bench_function("parse huge", |b| b.iter(|| parse(black_box(&huge_source))));
    group.finish();
}

criterion_group!(benches, bench);
criterion_main!(benches);