use criterion::{criterion_group, criterion_main, Criterion};
use glob::glob;
use glyphslib::Font;
use std::hint::black_box;

fn parse_many() -> Vec<Font> {
    let files = glob("resources/*.glyphs").expect("Failed to read glob pattern");
    let mut fonts = Vec::new();
    for file in files {
        let file = file.expect("Failed to read file");
        let font = Font::load(&file).expect("Failed to load font");
        fonts.push(font);
    }
    fonts
}

fn criterion_benchmark(c: &mut Criterion) {
    c.bench_function("Load fonts", |b| b.iter(|| black_box(parse_many())));
}

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