Skip to content

Commit bced219

Browse files
committed
Update perf test and results example
1 parent bd9f47e commit bced219

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

Diff for: Performance/run.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const { execSync } = require('node:child_process');
44

55
const implementations = [
6-
//['1-queue.js', 2048, 1],
6+
//['1-queue.js', 2048, 1],
77
['2-naïve.js', 2048, 1],
88
['3-fixed.js', 2048, 1],
99
['4-unrolled.js', 2048, 1],
@@ -22,7 +22,8 @@ const main = () => {
2222
for (const [file, nodeSize, poolSize] of implementations) {
2323
const options = `${file} ${rounds} ${ops} ${nodeSize} ${poolSize}`;
2424
console.log(`Test: ${options}`);
25-
const cmd = `node --expose-gc Performance/test.js ${options}`;
25+
const switches = '--nouse-idle-notification --expose-gc';
26+
const cmd = `node ${switches} Performance/test.js ${options}`;
2627
const out = execSync(cmd, { encoding: 'utf8' });
2728
results.push(out.replaceAll('\n', ','));
2829
}

Diff for: Performance/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const test = (queue, ops) => {
1616
queue.enqueue({ id: i });
1717
}
1818
for (let i = 0; i < ops; i++) {
19-
const { id } = queue.dequeue();
20-
preventOpt += id;
19+
const item = queue.dequeue();
20+
if (item) preventOpt += item.id;
2121
}
2222

2323
const t1 = performance.now();
@@ -40,8 +40,8 @@ const main = (file, rounds, ops, options) => {
4040
results.ram += ram;
4141
}
4242
}
43-
results.cpu = (results.cpu / rounds).toFixed(2);
44-
results.ram = (results.ram / rounds).toFixed(2);
43+
results.cpu = parseFloat((results.cpu / rounds).toFixed(2));
44+
results.ram = parseFloat((results.ram / rounds).toFixed(2));
4545
console.log(JSON.stringify({ name, ...results }));
4646
};
4747

Diff for: README.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@
2828
Run: `npm run perf`
2929

3030
```
31-
┌─────────┬────────────┬─────────┬────────────┐
32-
│ (index) │ name │ cpu │ ram │
33-
├─────────┼────────────┼─────────┼────────────┤
34-
│ 0 │ 'naïve' │ '43.03' │ '34928.97' │
35-
│ 1 │ 'fixed' │ '4.56' │ '19652.08' │
36-
│ 2 │ 'unrolled' │ '4.52' │ '19470.65' │
37-
│ 3 │ 'spare' │ '4.46' │ '19471.69' │
38-
│ 4 │ 'pool' │ '5.14' │ '19507.93' │
39-
│ 5 │ 'circular' │ '5.59' │ '19601.37' │
40-
│ 6 │ 'nodiv' │ '5.11' │ '19627.76' │
41-
└─────────┴────────────┴─────────┴────────────┘
31+
┌─────────┬────────────┬───────┬──────────┐
32+
│ (index) │ name │ cpu │ ram │
33+
├─────────┼────────────┼───────┼──────────┤
34+
│ 0 │ 'naïve' │ 58.57 │ 37454.62 │
35+
│ 1 │ 'fixed' │ 5.03 │ 19473.76 │
36+
│ 2 │ 'unrolled' │ 5.16 │ 19278.73 │
37+
│ 3 │ 'spare' │ 4.97 │ 19298.66 │
38+
│ 4 │ 'pool' │ 5.34 │ 19205.66 │
39+
│ 5 │ 'current' │ 5.3 │ 15610.69 │
40+
│ 6 │ 'circular' │ 5.24 │ 19242.05 │
41+
│ 7 │ 'nodiv' │ 4.97 │ 19314.83 │
42+
└─────────┴────────────┴───────┴──────────┘
4243
```

0 commit comments

Comments
 (0)