Skip to content

Commit

Permalink
chore: add performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Sep 16, 2022
1 parent 87bdc1c commit 2eace36
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ module.exports = {
},
{
// Specific rules for test files
files: ['**/test/**/*.ts'],
files: ['**/test/**/*.ts', '**/perf/**/*.ts'],
env: {
'jest/globals': true,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as path from 'path';
import { generateDeepTaxonomy, TARGET_RESULT } from 'deep-taxonomy-benchmark';
import { Factory } from 'sparqlalgebrajs';
import { QueryEngine } from '../lib';

async function deepTaxonomy(extended = false) {
for (let i = 1; i <= 6; i++) {
const engine = new QueryEngine();
const factory = new Factory();

const TITLE = `test-dl-${10 ** i}.n3`;
const store = generateDeepTaxonomy(10 ** i, extended);

// eslint-disable-next-line no-console
console.time(`Reasoning: ${TITLE}`);

const result = await engine.queryBoolean(
factory.createAsk(factory.createPattern(TARGET_RESULT.subject, TARGET_RESULT.predicate, TARGET_RESULT.object)),
{
sources: [ store ],
rules: path.join(__dirname, 'subclass.n3'),
},
);
if (!result) {
throw new Error('Target result not found');
}
// eslint-disable-next-line no-console
console.timeEnd(`Reasoning: ${TITLE}`);
}
}

deepTaxonomy()
.catch(error => {
// eslint-disable-next-line no-console
console.error(error);
});
4 changes: 4 additions & 0 deletions engines/query-sparql-file-reasoning/perf/subclass.n3
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

{ ?uuu rdfs:subClassOf ?xxx . ?vvv rdf:type ?uuu } => { ?vvv a ?xxx } .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

{ ?uuu rdfs:subClassOf ?xxx . ?vvv rdf:type ?uuu } => { ?vvv a ?xxx } .
{ ?uuu rdfs:subClassOf ?xxx . ?vvv rdf:type ?uuu } => { ?vvv a ?xxx } .
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"colors": "^1.4.0",
"componentsjs-generator": "^3.1.0",
"cross-fetch": "^3.1.5",
"deep-taxonomy-benchmark": "^1.0.0",
"depcheck": "^1.4.3",
"eslint": "^8.23.1",
"eslint-config-es": "4.2.0",
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6104,6 +6104,13 @@ deep-is@^0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831"
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==

deep-taxonomy-benchmark@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/deep-taxonomy-benchmark/-/deep-taxonomy-benchmark-1.0.0.tgz#de428c9a2425e31b20021b3ce074e241c0909f38"
integrity sha512-hOHIorWBsyTFTuAZHWWEz7jkxNbjvZeiW/mxl4BwHdYZxWHnqM95s/3Qs56qHt7Q6+M/cgzu6R9EbQBKWddFcw==
dependencies:
n3 "^1.16.2"

deepmerge@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955"
Expand Down

0 comments on commit 2eace36

Please sign in to comment.