use std::path::Path; use criterion::Criterion; use criterion::{black_box, criterion_group, criterion_main}; use imsearch::search_index::{Database, FeatureGenerator}; pub fn bench_images(c: &mut Criterion) { c.bench_function("indexing images", |b| { b.iter(|| { let files: Vec = std::fs::read_dir("res/benchmark/") .unwrap() .map(|f| f.unwrap().path()) .collect(); let feats: Vec = vec![ imsearch::feature::luminance_distribution, imsearch::feature::color_distribution, imsearch::feature::average_luminance, imsearch::feature::aspect_ratio, ]; let db = Database::new(&files, feats).unwrap(); black_box( db.search( Path::new("res/benchmark/bird.png"), imsearch::feature::luminance_distribution, ) .unwrap(), ); }) }); } criterion_group!(benches, bench_images); criterion_main!(benches);