@naturalcycles/bench-lib 1.6.4 → 1.6.6
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.util.js +6 -6
- package/dist/cannon.util.js +6 -6
- package/package.json +3 -3
package/dist/bench.util.js
CHANGED
|
@@ -3,8 +3,8 @@ 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
5
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
7
|
+
const nodejs_lib_3 = require("@naturalcycles/nodejs-lib");
|
|
8
8
|
const Benchmark = require("benchmark");
|
|
9
9
|
const vega = require("vega");
|
|
10
10
|
const vegaLite = require("vega-lite");
|
|
@@ -15,7 +15,7 @@ const asciiChart_util_1 = require("./asciiChart.util");
|
|
|
15
15
|
function runBenchScript(opt) {
|
|
16
16
|
// fake timeout is needed to workaround `benchmark` process exiting too early when 2+ runs are used
|
|
17
17
|
const timeout = setTimeout(() => { }, 10000000);
|
|
18
|
-
(0,
|
|
18
|
+
(0, nodejs_lib_3.runScript)(async () => {
|
|
19
19
|
await runBench(opt);
|
|
20
20
|
clearTimeout(timeout);
|
|
21
21
|
});
|
|
@@ -49,7 +49,7 @@ async function runBench(opt) {
|
|
|
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
|
-
console.log(`saved ${(0,
|
|
52
|
+
console.log(`saved ${(0, nodejs_lib_2.dimGrey)(summaryJsonPath)}`);
|
|
53
53
|
}
|
|
54
54
|
if (writePlot) {
|
|
55
55
|
(0, nodejs_lib_1._ensureDirSync)(reportDirPath);
|
|
@@ -58,7 +58,7 @@ async function runBench(opt) {
|
|
|
58
58
|
const svg = await view.toSVG();
|
|
59
59
|
const plotPath = `${reportDirPath}/${name}.svg`;
|
|
60
60
|
(0, nodejs_lib_1._writeFileSync)(plotPath, svg);
|
|
61
|
-
console.log(`saved ${(0,
|
|
61
|
+
console.log(`saved ${(0, nodejs_lib_2.dimGrey)(plotPath)}`);
|
|
62
62
|
}
|
|
63
63
|
if (asciiPlot) {
|
|
64
64
|
console.log('\n' + (0, asciiChart_util_1.plotAsciiChart)(avg));
|
|
@@ -74,7 +74,7 @@ async function runBenchOnce(opt, run) {
|
|
|
74
74
|
// console.log(event.target)
|
|
75
75
|
})
|
|
76
76
|
.on('complete', function () {
|
|
77
|
-
console.log(`Fastest in run ${(0,
|
|
77
|
+
console.log(`Fastest in run ${(0, nodejs_lib_2.yellow)(run)} is ` + this.filter('fastest').map('name'));
|
|
78
78
|
// console.log(this[0].stats)
|
|
79
79
|
// console.log(this)
|
|
80
80
|
const results = {};
|
package/dist/cannon.util.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCannon = exports.runCannonScript = void 0;
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const
|
|
5
|
+
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
6
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
|
-
const
|
|
7
|
+
const nodejs_lib_3 = require("@naturalcycles/nodejs-lib");
|
|
8
8
|
const vega = require("vega");
|
|
9
9
|
const vegaLite = require("vega-lite");
|
|
10
10
|
/**
|
|
@@ -13,7 +13,7 @@ const vegaLite = require("vega-lite");
|
|
|
13
13
|
function runCannonScript(profiles, optInput = {}) {
|
|
14
14
|
// fake timeout is needed to workaround `benchmark` process exiting too early when 2+ runs are used
|
|
15
15
|
const timeout = setTimeout(() => { }, 10000000);
|
|
16
|
-
(0,
|
|
16
|
+
(0, nodejs_lib_2.runScript)(async () => {
|
|
17
17
|
await runCannon(profiles, optInput);
|
|
18
18
|
clearTimeout(timeout);
|
|
19
19
|
});
|
|
@@ -68,7 +68,7 @@ async function runCannon(profiles, optInput = {}) {
|
|
|
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
|
-
console.log(`saved ${(0,
|
|
71
|
+
console.log(`saved ${(0, nodejs_lib_3.dimGrey)(summaryJsonPath)}`);
|
|
72
72
|
}
|
|
73
73
|
if (opt.writeRawSummary) {
|
|
74
74
|
(0, nodejs_lib_1._writeJsonSync)(`${reportDirPath}/${opt.name}.rawSummary.json`, resultByProfile, { spaces: 2 });
|
|
@@ -88,7 +88,7 @@ async function runCannonProfile(profileName, serverFactory, opt) {
|
|
|
88
88
|
const url = `${host}:${port}${opt.path}`;
|
|
89
89
|
let finalResult = undefined;
|
|
90
90
|
for await (const run of (0, js_lib_1._range)(1, runs + 1)) {
|
|
91
|
-
console.log(`\n${(0,
|
|
91
|
+
console.log(`\n${(0, nodejs_lib_3.boldRed)('=== ' + profileName + ' ===')} run ${(0, nodejs_lib_3.yellow)(run)}/${(0, nodejs_lib_3.yellow)(runs)}\n`);
|
|
92
92
|
const doneDefer = (0, js_lib_1.pDefer)();
|
|
93
93
|
const instance = autocannon({
|
|
94
94
|
url,
|
|
@@ -112,7 +112,7 @@ async function runCannonProfile(profileName, serverFactory, opt) {
|
|
|
112
112
|
});
|
|
113
113
|
finalResult = await doneDefer;
|
|
114
114
|
if (!silent)
|
|
115
|
-
console.log((0,
|
|
115
|
+
console.log((0, nodejs_lib_3.dimGrey)(`cooldown ${(0, nodejs_lib_3.yellow)(cooldown)} seconds...`));
|
|
116
116
|
await (0, js_lib_1.pDelay)(cooldown * 1000);
|
|
117
117
|
}
|
|
118
118
|
await new Promise(resolve => server.close(resolve));
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@naturalcycles/js-lib": "^14.0.0",
|
|
8
|
-
"@naturalcycles/nodejs-lib": "^
|
|
8
|
+
"@naturalcycles/nodejs-lib": "^13.0.2",
|
|
9
9
|
"autocannon": "^7.0.0",
|
|
10
10
|
"benchmark": "^2.1.4",
|
|
11
11
|
"express": "^4.17.1",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"url": "https://github.com/NaturalCycles/bench-lib"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
37
|
+
"node": ">=18.12.0"
|
|
38
38
|
},
|
|
39
|
-
"version": "1.6.
|
|
39
|
+
"version": "1.6.6",
|
|
40
40
|
"description": "Benchmarking library, based on Benchmark.js and Autocannon",
|
|
41
41
|
"author": "Natural Cycles Team",
|
|
42
42
|
"license": "MIT"
|