use criterion; use chiral_db_sources; use chiral_db; fn criterion_benchmark(c: &mut criterion::Criterion) { let filepath = std::path::Path::new("../chiral-db-example-data/ChEMBL/chembl_30_chemreps_10k.txt"); let sc = chiral_db_sources::chembl::SourceChembl::new(&filepath); let (smiles_vec, ids) = sc.get_smiles_id_pairs(); let smarts = String::from("Cc1cc(NC(=O)c2cc(Cl)cc(Cl)c2O)ccc1Sc1nc2ccccc2s1"); let mut group = c.benchmark_group("Benchmark query substructure"); for &count in vec![100, 200, 500, 1000].iter() { let sd = chiral_db::substructure::SMILESDocument::new_from_smiles_vec(&smiles_vec[..count].to_vec(), &ids[..count].to_vec()); group.bench_function(format!("Query substructure in {} mols", count).as_str(), |b| b.iter(|| chiral_db::substructure::query_substructure(&chiral_db::types::Toolkit::OpenBabel, criterion::black_box(&smarts), criterion::black_box(&sd)))); } } criterion::criterion_group!(benches, criterion_benchmark); criterion::criterion_main!(benches);