use criterion::{Criterion, criterion_group, criterion_main}; use std::hint::black_box; use std::fs; use wmap_renderer::{Configuration, StageType, render_to_surface}; fn benchmark_rendering(c: &mut Criterion) { let configuration = Configuration::default(); let mut configuration_no_smart = Configuration::default(); configuration_no_smart.options.smart_label_positioning = false; let example_source = fs::read_to_string("benches/example.wmap").expect("Failed to read benches/example.wmap"); let example_map = wmap_parser::parse(&example_source); c.bench_function("render example map", |b| { b.iter(|| { render_to_surface( black_box(&example_map), StageType::default(), &configuration, ) }); }); c.bench_function("render example map (no smart labels))", |b| { b.iter(|| { render_to_surface( black_box(&example_map), StageType::default(), &configuration_no_smart, ) }); }); let huge_source = fs::read_to_string("benches/huge.wmap").expect("Failed to read benches/huge.wmap"); let huge_map = wmap_parser::parse(&huge_source); c.bench_function("render huge map", |b| { b.iter(|| render_to_surface(black_box(&huge_map), StageType::default(), &configuration)); }); c.bench_function("render huge map", |b| { b.iter(|| { render_to_surface( black_box(&huge_map), StageType::default(), &configuration_no_smart, ) }); }); } criterion_group!(benches, benchmark_rendering); criterion_main!(benches);