Skip to content

Commit

Permalink
test: add benchmark focussed on idCode (#153)
Browse files Browse the repository at this point in the history
* test: add benchmark focussed on idCode

* chore: improve benchmark
  • Loading branch information
lpatiny committed Jan 31, 2023
1 parent ce15aff commit f688501
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
24 changes: 24 additions & 0 deletions benchmark/diastereoID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const { getDiastereotopicAtomIDs } = require('openchemlib-utils');

const { Molecule, version } = require('../dist/openchemlib-full');

async function doAll() {
console.log('OCL version', version);
console.time('diastereoID');
const response = await fetch(
'https://wikipedia.cheminfo.org/src/json/data.json',
);
const entries = (await response.json()).data.molecules;
let totalLength = 0;
for (const entry of entries.slice(0, 700)) {
const molecule = Molecule.fromIDCode(entry.actID.value);
const ids = getDiastereotopicAtomIDs(molecule);
totalLength += ids.length;
}
console.timeEnd('diastereoID');
console.log(totalLength);
}

doAll();
22 changes: 22 additions & 0 deletions benchmark/wikipedia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const { Molecule, version } = require('../dist/openchemlib-full');

async function doAll() {
console.log('OCL version', version);
console.time('wikipedia');
const response = await fetch(
'https://wikipedia.cheminfo.org/src/json/data.json',
);
const entries = (await response.json()).data.molecules;
const idCodes = [];
for (const entry of entries.slice(0, 10000)) {
const molecule = Molecule.fromIDCode(entry.actID.value);
const idCode = molecule.getIDCode();
idCodes.push(idCode);
}
console.timeEnd('wikipedia');
console.log(idCodes.join(',').length);
}

doAll();

0 comments on commit f688501

Please sign in to comment.