@naturalcycles/bench-lib 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bench.model.d.ts +1 -1
- package/dist/bench.util.js +5 -6
- package/dist/cannon.util.js +7 -7
- package/package.json +3 -4
package/dist/bench.model.d.ts
CHANGED
package/dist/bench.util.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runBench = exports.runBenchScript = void 0;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
6
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
6
7
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
7
8
|
const Benchmark = require("benchmark");
|
|
8
|
-
const fs = require("fs-extra");
|
|
9
9
|
const vega = require("vega");
|
|
10
10
|
const vegaLite = require("vega-lite");
|
|
11
11
|
const asciiChart_util_1 = require("./asciiChart.util");
|
|
@@ -46,18 +46,18 @@ async function runBench(opt) {
|
|
|
46
46
|
// names.forEach(name => {
|
|
47
47
|
// summary[name] = results.hz.map(map => map[name]!)
|
|
48
48
|
// })
|
|
49
|
-
|
|
49
|
+
(0, nodejs_lib_1._ensureDirSync)(reportDirPath);
|
|
50
50
|
const summaryJsonPath = `${reportDirPath}/${name}.json`;
|
|
51
|
-
|
|
51
|
+
(0, nodejs_lib_1._writeJsonSync)(summaryJsonPath, avg, { spaces: 2 });
|
|
52
52
|
console.log(`saved ${(0, colors_1.dimGrey)(summaryJsonPath)}`);
|
|
53
53
|
}
|
|
54
54
|
if (writePlot) {
|
|
55
|
-
|
|
55
|
+
(0, nodejs_lib_1._ensureDirSync)(reportDirPath);
|
|
56
56
|
const spec = benchResultsToVegaSpec(avg);
|
|
57
57
|
const view = new vega.View(vega.parse(spec), { renderer: 'none' });
|
|
58
58
|
const svg = await view.toSVG();
|
|
59
59
|
const plotPath = `${reportDirPath}/${name}.svg`;
|
|
60
|
-
|
|
60
|
+
(0, nodejs_lib_1._writeFileSync)(plotPath, svg);
|
|
61
61
|
console.log(`saved ${(0, colors_1.dimGrey)(plotPath)}`);
|
|
62
62
|
}
|
|
63
63
|
if (asciiPlot) {
|
|
@@ -74,7 +74,6 @@ async function runBenchOnce(opt, run) {
|
|
|
74
74
|
// console.log(event.target)
|
|
75
75
|
})
|
|
76
76
|
.on('complete', function () {
|
|
77
|
-
// eslint-disable-next-line unicorn/no-array-callback-reference
|
|
78
77
|
console.log(`Fastest in run ${(0, colors_1.yellow)(run)} is ` + this.filter('fastest').map('name'));
|
|
79
78
|
// console.log(this[0].stats)
|
|
80
79
|
// console.log(this)
|
package/dist/cannon.util.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCannon = exports.runCannonScript = void 0;
|
|
4
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
4
5
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
7
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
7
|
-
const fs = require("fs-extra");
|
|
8
8
|
const vega = require("vega");
|
|
9
9
|
const vegaLite = require("vega-lite");
|
|
10
10
|
/**
|
|
@@ -53,7 +53,7 @@ async function runCannon(profiles, optInput = {}) {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
const { reportDirPath } = opt;
|
|
56
|
-
|
|
56
|
+
(0, nodejs_lib_1._ensureDirSync)(reportDirPath);
|
|
57
57
|
const resultByProfile = {};
|
|
58
58
|
const summaries = [];
|
|
59
59
|
for await (const profileName of Object.keys(profiles)) {
|
|
@@ -67,11 +67,11 @@ async function runCannon(profiles, optInput = {}) {
|
|
|
67
67
|
console.table(summaries);
|
|
68
68
|
if (opt.writeSummary) {
|
|
69
69
|
const summaryJsonPath = `${reportDirPath}/${opt.name}.summary.json`;
|
|
70
|
-
|
|
70
|
+
(0, nodejs_lib_1._writeJsonSync)(summaryJsonPath, summaries, { spaces: 2 });
|
|
71
71
|
console.log(`saved ${(0, colors_1.dimGrey)(summaryJsonPath)}`);
|
|
72
72
|
}
|
|
73
73
|
if (opt.writeRawSummary) {
|
|
74
|
-
|
|
74
|
+
(0, nodejs_lib_1._writeJsonSync)(`${reportDirPath}/${opt.name}.rawSummary.json`, resultByProfile, { spaces: 2 });
|
|
75
75
|
}
|
|
76
76
|
if (opt.writePlots) {
|
|
77
77
|
await writePlotFiles(opt, summaries);
|
|
@@ -135,7 +135,7 @@ function toSummary(name, result) {
|
|
|
135
135
|
}
|
|
136
136
|
async function writePlotFiles(opt, summaries) {
|
|
137
137
|
const { reportDirPath, name } = opt;
|
|
138
|
-
|
|
138
|
+
(0, nodejs_lib_1._ensureDirSync)(reportDirPath);
|
|
139
139
|
let fields = ['rpsAvg', 'latencyAvg', 'latency50', 'latency90', 'latency99', 'throughputAvg'];
|
|
140
140
|
if (!opt.includeLatencyPercentiles) {
|
|
141
141
|
fields = fields.filter(f => !f.startsWith('latency') || f === 'latencyAvg');
|
|
@@ -147,9 +147,9 @@ async function writePlotFiles(opt, summaries) {
|
|
|
147
147
|
// generate a static SVG image
|
|
148
148
|
const svg = await view.toSVG();
|
|
149
149
|
// console.log(svg)
|
|
150
|
-
|
|
150
|
+
(0, nodejs_lib_1._writeFileSync)(`${reportDirPath}/${name}.${specName}.svg`, svg);
|
|
151
151
|
});
|
|
152
|
-
|
|
152
|
+
(0, nodejs_lib_1._writeFileSync)(`${reportDirPath}/${name}.md`, mdContent(opt, Object.keys(specs)));
|
|
153
153
|
}
|
|
154
154
|
function autocannonSummaryToVegaSpecs(fields, summaries) {
|
|
155
155
|
// console.log(summary)
|
package/package.json
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"autocannon": "^7.0.0",
|
|
10
10
|
"benchmark": "^2.1.4",
|
|
11
11
|
"express": "^4.17.1",
|
|
12
|
-
"
|
|
13
|
-
"helmet": "^6.0.0",
|
|
12
|
+
"helmet": "^7.0.0",
|
|
14
13
|
"vega": "^5.10.1",
|
|
15
14
|
"vega-lite": "^5.0.0"
|
|
16
15
|
},
|
|
@@ -18,7 +17,7 @@
|
|
|
18
17
|
"@naturalcycles/dev-lib": "^13.6.0",
|
|
19
18
|
"@types/benchmark": "^2.1.0",
|
|
20
19
|
"@types/express": "^4.17.6",
|
|
21
|
-
"@types/node": "^
|
|
20
|
+
"@types/node": "^20.1.0",
|
|
22
21
|
"fastify": "^4.6.0",
|
|
23
22
|
"jest": "^29.0.3"
|
|
24
23
|
},
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"engines": {
|
|
38
37
|
"node": ">=16.10.0"
|
|
39
38
|
},
|
|
40
|
-
"version": "1.6.
|
|
39
|
+
"version": "1.6.4",
|
|
41
40
|
"description": "Benchmarking library, based on Benchmark.js and Autocannon",
|
|
42
41
|
"author": "Natural Cycles Team",
|
|
43
42
|
"license": "MIT"
|