use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use gramatika::Lexer as _; use utils::hashmap; use wgsl_parser::token::Lexer; criterion_group!(benches, lexer); criterion_main!(benches); pub fn lexer(c: &mut Criterion) { let mut group = c.benchmark_group("Lexer"); 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("Lexer", key); group.bench_with_input(name, program, move |b, input| { b.iter_with_large_drop(|| Lexer::new(input.into()).scan()) }); } group.finish(); }