-
Notifications
You must be signed in to change notification settings - Fork 0
Add benchmarks for indexing and searching #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JJ-Pineda
wants to merge
2
commits into
main
Choose a base branch
from
add_benchmarks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #![feature(test)] | ||
|
|
||
| use cheminee::search::compound_processing::*; | ||
|
|
||
| extern crate test; | ||
| use rdkit::ROMol; | ||
| use test::Bencher; | ||
|
|
||
| #[bench] | ||
| fn bench_process_cpd(b: &mut Bencher) { | ||
| let smiles1 = | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O"; | ||
|
|
||
| b.iter(|| { | ||
| let _ = process_cpd(smiles1, false); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_process_cpd ... bench: 5,527,616.65 ns/iter (+/- 337,547.33) | ||
|
|
||
| #[bench] | ||
| fn bench_standardize_mol(b: &mut Bencher) { | ||
| let mol = ROMol::from_smiles( | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O", | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| b.iter(|| { | ||
| let _ = standardize_mol(&mol); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_standardize_mol ... bench: 3,906,768.75 ns/iter (+/- 230,949.77) | ||
|
|
||
| #[bench] | ||
| fn bench_get_cpd_properties(b: &mut Bencher) { | ||
| let smiles1 = | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O"; | ||
| let canon_taut = standardize_smiles(smiles1, false).unwrap(); | ||
|
|
||
| b.iter(|| { | ||
| let _ = get_cpd_properties(&canon_taut); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_get_cpd_properties ... bench: 1,329,194.77 ns/iter (+/- 183,436.78) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #![feature(test)] | ||
|
|
||
| extern crate test; | ||
|
|
||
| use cheminee::command_line::indexing::bulk_index::create_tantivy_doc; | ||
| use cheminee::indexing::KNOWN_DESCRIPTORS; | ||
| use cheminee::schema::LIBRARY; | ||
| use serde_json::Value; | ||
| use std::collections::HashMap; | ||
| use tantivy::schema::Field; | ||
| use test::Bencher; | ||
|
|
||
| #[bench] | ||
| fn bench_create_tantivy_doc(b: &mut Bencher) { | ||
| let schema = LIBRARY.get("descriptor_v1").unwrap().clone(); | ||
| let smiles_field = schema.get_field("smiles").unwrap(); | ||
| let fingerprint_field = schema.get_field("fingerprint").unwrap(); | ||
| let extra_data_field = schema.get_field("extra_data").unwrap(); | ||
| let descriptor_fields = KNOWN_DESCRIPTORS | ||
| .iter() | ||
| .map(|kd| (*kd, schema.get_field(kd).unwrap())) | ||
| .collect::<HashMap<&str, Field>>(); | ||
|
|
||
| let smi = | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O"; | ||
| let mut map = serde_json::Map::new(); | ||
| map.insert("smiles".to_string(), Value::String(smi.to_string())); | ||
|
|
||
| let record: Value = Value::Object(map); | ||
|
|
||
| b.iter(|| { | ||
| let _ = create_tantivy_doc( | ||
| record.clone(), | ||
| smiles_field, | ||
| fingerprint_field, | ||
| &descriptor_fields, | ||
| extra_data_field, | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_create_tantivy_doc ... bench: 6,527,306.20 ns/iter (+/- 562,411.21) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #![feature(test)] | ||
|
|
||
| extern crate test; | ||
| use cheminee::search::structure_matching::exact_match; | ||
| use rdkit::{substruct_match, ROMol, SubstructMatchParameters}; | ||
| use test::Bencher; | ||
|
|
||
| #[bench] | ||
| fn bench_exact_match_no_chirality(b: &mut Bencher) { | ||
| let romol1 = ROMol::from_smiles( | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O", | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let romol2 = romol1.clone(); | ||
|
|
||
| b.iter(|| { | ||
| let _ = exact_match(&romol1, &romol2, false); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_exact_match_no_chirality ... bench: 10,117.06 ns/iter (+/- 423.84) | ||
|
|
||
| #[bench] | ||
| fn bench_exact_match_yes_chirality(b: &mut Bencher) { | ||
| let romol1 = ROMol::from_smiles( | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O", | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let romol2 = romol1.clone(); | ||
|
|
||
| b.iter(|| { | ||
| let _ = exact_match(&romol1, &romol2, true); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_exact_match_yes_chirality ... bench: 18,131.02 ns/iter (+/- 790.45) | ||
|
|
||
| #[bench] | ||
| fn bench_substructure_match_no_chirality(b: &mut Bencher) { | ||
| let super_mol = ROMol::from_smiles( | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O", | ||
| ) | ||
| .unwrap(); | ||
| let sub_mol = | ||
| ROMol::from_smiles("C[C@@H]1[C@H]([C@H]([C@@H](O1)[N]2C=NC3=C(N=CN=C23)N)O)O").unwrap(); | ||
|
|
||
| let mut params = SubstructMatchParameters::default(); | ||
| params.set_use_chirality(false); | ||
|
|
||
| b.iter(|| { | ||
| let _ = substruct_match(&super_mol, &sub_mol, ¶ms); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_substructure_match_no_chirality ... bench: 4,209.80 ns/iter (+/- 318.14) | ||
|
|
||
| #[bench] | ||
| fn bench_substructure_match_yes_chirality(b: &mut Bencher) { | ||
| let super_mol = ROMol::from_smiles( | ||
| "C[S+](CC[C@@H](C(=O)[O-])[NH3+])C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O", | ||
| ) | ||
| .unwrap(); | ||
| let sub_mol = | ||
| ROMol::from_smiles("C[C@@H]1[C@H]([C@H]([C@@H](O1)[N]2C=NC3=C(N=CN=C23)N)O)O").unwrap(); | ||
|
|
||
| let mut params = SubstructMatchParameters::default(); | ||
| params.set_use_chirality(true); | ||
|
|
||
| b.iter(|| { | ||
| let _ = substruct_match(&super_mol, &sub_mol, ¶ms); | ||
| }); | ||
| } | ||
|
|
||
| // running 1 test | ||
| // test bench_substructure_match_yes_chirality ... bench: 7,313.00 ns/iter (+/- 532.24) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.