Files
rdkit/Code/Bench/molops.cpp
Andrew Dirksen abfddf2a79 add more benchmarking (#8878)
* Add many new c++ catch2 performance benchmarks.

* inline splitmix64 from boost, splitmix64 is not always available in boost. fun fact, this version is ~twice as fast

* reduce intensity of memory pressure test, target 200MB usage.

* new bench compound; accept suggestion from code review

* bench MolToCXSmiles

* Update Code/Bench/stereo.cpp

* impl first part of the suggestions from code reveiw

* impl second part of the suggestions from code reveiw
2025-11-27 17:38:24 +01:00

49 lines
1.1 KiB
C++

#include <catch2/catch_all.hpp>
#include <string>
#include "bench_common.hpp"
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/MolOps.h>
using namespace RDKit;
TEST_CASE("MolOps::addHs", "[molops]") {
auto samples = bench_common::load_samples();
BENCHMARK("MolOps::addHs") {
auto total_atoms = 0;
for (auto &mol : samples) {
RWMol mol_copy(mol);
MolOps::addHs(mol_copy);
total_atoms += mol_copy.getNumAtoms();
}
return total_atoms;
};
}
TEST_CASE("MolOps::FindSSR", "[molops]") {
auto samples = bench_common::load_samples();
BENCHMARK("MolOps::FindSSR") {
auto total = 0;
for (auto &mol : samples) {
total += MolOps::findSSSR(mol);
}
return total;
};
}
TEST_CASE("MolOps::getMolFrags", "[molops]") {
auto samples = bench_common::load_samples();
BENCHMARK("MolOps::getMolFrags") {
auto total = 0;
for (auto &mol : samples) {
std::vector<std::unique_ptr<ROMol>> frags;
MolOps::getMolFrags(mol, frags);
for (auto &frag : frags) {
total += frag->getNumAtoms();
}
}
return total;
};
}