-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmarkWasmInit.js
More file actions
47 lines (31 loc) · 1.16 KB
/
benchmarkWasmInit.js
File metadata and controls
47 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const QueryEngineFactory = require('@comunica-crop/engines/query-sparql').QueryEngineFactory;
const fs = require('fs/promises');
// Run with --experimental-wasi-unstable-preview1
const replication = 20;
const query = 'SELECT * WHERE {' +
'?v0 <http://xmlns.com/foaf/homepage> ?v1 .' +
'?v0 <http://ogp.me/ns#title> ?v1 . ' +
'}';
const sources = [`http://localhost:5000/data100k`];
async function run() {
let times = []
for (let i = 0; i < replication; i++) {
const engine = await new QueryEngineFactory().create({
configPath: `config/engines/server/config-crop.json`,
});
const initTime = (id, elapsedTime) => {
if (id === "optimization-time") {
times.push(elapsedTime);
console.log(elapsedTime);
}
};
await engine.queryBindings(query, {
sources: sources,
benchmarkTimeLog: initTime,
overrideCropSettings: { k: 2, skipEval: true, mode: 'wasm' }}
);
}
const mean = times.reduce((a, b) => a + b, 0) / times.length;
console.log(`Instantiating WASM took ${mean}ms`);
}
run().then(() => {});