use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use gramatika::ParseStreamer; use utils::hashmap; use wgsl_parser::{ParseStream, SyntaxTree}; criterion_group!(benches, parsing); criterion_main!(benches); pub fn parsing(c: &mut Criterion) { let mut group = c.benchmark_group("Parsing"); group.confidence_level(0.99); let programs = hashmap![ // "shader.wgsl" => include_str!("../test-files/shader.wgsl"), "boids.wgsl" => include_str!("../test-files/boids.wgsl"), "shadow.wgsl" => include_str!("../test-files/shadow.wgsl"), "water.wgsl" => include_str!("../test-files/water.wgsl"), "mesh.wgsl" => include_str!("../test-files/mesh.wgsl"), "modules/pbr_functions.wgsl" => include_str!("../test-files/modules/pbr_functions.wgsl"), ]; for (key, program) in programs { let name = BenchmarkId::new("Parser", key); group.bench_with_input(name, program, move |b, input| { b.iter_with_large_drop(|| match ParseStream::from(input).parse::() { Ok(tree) => tree, Err(err) => panic!("{}", err), }); }); } group.finish(); }