Skip to content

Commit

Permalink
chore: add data generator file (#442)
Browse files Browse the repository at this point in the history
* chore: add data generator file

* chore: fix lint errors

* Update .gitignore
  • Loading branch information
jeswr authored Sep 17, 2024
1 parent 90c9512 commit 86a388e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ docs
lib
node_modules
coverage
perf/data/*.trig
28 changes: 28 additions & 0 deletions perf/data/trigGen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require('fs');
const path = require('path');
const N3 = require('../../lib');

const { quad, namedNode, literal } = N3.DataFactory;
const dim = 30;

const writer = new N3.StreamWriter();

// eslint-disable-next-line
fs.rmSync(path.join(__dirname, 'data.trig'), { force: true });
const outputStream = fs.createWriteStream(path.join(__dirname, 'data.trig'));
writer.pipe(outputStream);

const prefix = 'http://example.org/#';
for (let i = 0; i < dim; i++) {
for (let j = 0; j < dim; j++) {
for (let k = 0; k < dim; k++) {
for (let l = 0; l < dim; l++) {
writer.write(quad(
namedNode(prefix + i), namedNode(prefix + j), (k % 2 === 0 ? namedNode : literal)(prefix + k), namedNode(prefix + l),
));
}
}
}
}

writer.end();

0 comments on commit 86a388e

Please sign in to comment.