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 = String::from("Cc1cc(NC(=O)c2cc(Cl)cc(Cl)c2O)ccc1Sc1nc2ccccc2s1"); 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 query similarity tanimoto"); for &count in vec![1000, 2000, 5000, 10000].iter() { let fp_doc = chiral_db::fingerprint::FingerprintDocument::new_from_smiles_vec(&fpk, nbits, &smiles_new[..count].to_vec(), &ids[..count].to_vec()); let fpd_query = chiral_db::fingerprint::get_fingerprint_for_smiles(&fp_doc, &smiles); group.bench_function(format!("Query similarity in {} mols", count).as_str(), |b| b.iter(|| chiral_db::similarity::query_similarity(criterion::black_box(&fpd_query), criterion::black_box(&fp_doc), 0.5))); } } criterion::criterion_group!(benches, criterion_benchmark); criterion::criterion_main!(benches);