use criterion; use chiral_db_sources; use chiral_db; fn criterion_benchmark(c: &mut criterion::Criterion) { let fpk = chiral_db::types::FingerprintKind::OpenBabelECFP4; let nbits: u32 = 2048; 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 smiles_new: Vec = smiles_vec.iter().map(|&s| s.to_owned()).collect(); let mut group = c.benchmark_group("Benchmark fingerpint generating"); for &count in vec![100, 200, 500, 1000].iter() { if count == 500 { group.measurement_time(std::time::Duration::new(10, 0)); } else if count == 1000 { group.measurement_time(std::time::Duration::new(20, 0)); } else { group.measurement_time(std::time::Duration::new(5, 0)); } group.bench_function(format!("Fingerprint document generation - {} mols", count).as_str(), |b| b.iter(|| chiral_db::fingerprint::FingerprintDocument::new_from_smiles_vec(&fpk, nbits, criterion::black_box(&smiles_new[..count].to_vec()), criterion::black_box(&ids[..count].to_vec())))); } } criterion::criterion_group!(benches, criterion_benchmark); criterion::criterion_main!(benches);