@naturalcycles/bench-lib 1.6.0 → 1.6.2
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 +3 -3
- package/dist/bench.util.js +8 -5
- package/dist/cannon.model.d.ts +3 -2
- package/dist/cannon.profiles.js +1 -1
- package/dist/cannon.util.js +6 -3
- package/package.json +8 -8
- package/CHANGELOG.md +0 -97
package/dist/bench.model.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface BenchDeferred {
|
|
2
2
|
resolve(): void;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
4
|
+
export type BenchDeferredFunction = (done: BenchDeferred) => any;
|
|
5
5
|
export interface RunBenchOptions {
|
|
6
6
|
/**
|
|
7
7
|
* Functions to benchmark.
|
|
@@ -9,7 +9,7 @@ export interface RunBenchOptions {
|
|
|
9
9
|
* BenchDeferredFunction takes `done` callback as a first argument,
|
|
10
10
|
* `done.resolve()` HAS to be called at the end of your function.
|
|
11
11
|
*/
|
|
12
|
-
fns
|
|
12
|
+
fns: Record<string, BenchDeferredFunction>;
|
|
13
13
|
/**
|
|
14
14
|
* How many times to run.
|
|
15
15
|
* Every second run will be in reverse order.
|
|
@@ -59,4 +59,4 @@ export interface RunBenchOptions {
|
|
|
59
59
|
/**
|
|
60
60
|
* results[fnName] = 100 // ops/sec, or "hertz"
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
62
|
+
export type HertzMap = Record<string, number>;
|
package/dist/bench.util.js
CHANGED
|
@@ -3,6 +3,7 @@ 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 colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
6
|
+
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
6
7
|
const Benchmark = require("benchmark");
|
|
7
8
|
const fs = require("fs-extra");
|
|
8
9
|
const vega = require("vega");
|
|
@@ -12,9 +13,11 @@ const asciiChart_util_1 = require("./asciiChart.util");
|
|
|
12
13
|
* Wraps `runBench` in `runScript` for convenience, so it can be run in top-level without `await`.
|
|
13
14
|
*/
|
|
14
15
|
function runBenchScript(opt) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// fake timeout is needed to workaround `benchmark` process exiting too early when 2+ runs are used
|
|
17
|
+
const timeout = setTimeout(() => { }, 10000000);
|
|
18
|
+
(0, script_1.runScript)(async () => {
|
|
19
|
+
await runBench(opt);
|
|
20
|
+
clearTimeout(timeout);
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
23
|
exports.runBenchScript = runBenchScript;
|
|
@@ -24,7 +27,7 @@ exports.runBenchScript = runBenchScript;
|
|
|
24
27
|
async function runBench(opt) {
|
|
25
28
|
const { runs = 1, writeSummary = true, writePlot = true, asciiPlot = true, name = 'runBench', } = opt;
|
|
26
29
|
const { reportDirPath = `./tmp/${name}` } = opt;
|
|
27
|
-
console.log(
|
|
30
|
+
console.log(`running benchmark...\n\n`);
|
|
28
31
|
const results = [];
|
|
29
32
|
for await (const run of (0, js_lib_1._range)(1, runs + 1)) {
|
|
30
33
|
results.push(await runBenchOnce(opt, run));
|
|
@@ -82,7 +85,7 @@ async function runBenchOnce(opt, run) {
|
|
|
82
85
|
defer.resolve(results);
|
|
83
86
|
})
|
|
84
87
|
.on('error', function (event) {
|
|
85
|
-
console.log(event.target.error);
|
|
88
|
+
console.log('bench error:\n', event.target.error);
|
|
86
89
|
});
|
|
87
90
|
const fnNames = Object.keys(opt.fns || {});
|
|
88
91
|
if (run % 2 === 0)
|
package/dist/cannon.model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type * as http from 'node:http';
|
|
4
|
+
export type HttpServerFactory = () => Promise<http.Server>;
|
|
4
5
|
export interface AutocannonOptions {
|
|
5
6
|
body?: string | Buffer;
|
|
6
7
|
method?: string;
|
package/dist/cannon.profiles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.expressSyncFunctionFactory = exports.expressFunctionFactory = exports.expressWithMiddlewaresServerFactory = exports.bareExpressServerFactory = exports.bareNodeServerFactory = void 0;
|
|
4
|
-
const http = require("http");
|
|
4
|
+
const http = require("node:http");
|
|
5
5
|
const express = require("express");
|
|
6
6
|
const helmet = require("helmet");
|
|
7
7
|
const bareNodeServerFactory = async () => {
|
package/dist/cannon.util.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCannon = exports.runCannonScript = void 0;
|
|
4
|
+
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
4
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
6
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
6
7
|
const fs = require("fs-extra");
|
|
@@ -10,9 +11,11 @@ const vegaLite = require("vega-lite");
|
|
|
10
11
|
* Wraps `runBench` in `runScript` for convenience, so it can be run in top-level without `await`.
|
|
11
12
|
*/
|
|
12
13
|
function runCannonScript(profiles, optInput = {}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// fake timeout is needed to workaround `benchmark` process exiting too early when 2+ runs are used
|
|
15
|
+
const timeout = setTimeout(() => { }, 10000000);
|
|
16
|
+
(0, script_1.runScript)(async () => {
|
|
17
|
+
await runCannon(profiles, optInput);
|
|
18
|
+
clearTimeout(timeout);
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
21
|
exports.runCannonScript = runCannonScript;
|
package/package.json
CHANGED
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
"autocannon": "^7.0.0",
|
|
10
10
|
"benchmark": "^2.1.4",
|
|
11
11
|
"express": "^4.17.1",
|
|
12
|
-
"fs-extra": "^
|
|
13
|
-
"helmet": "^
|
|
12
|
+
"fs-extra": "^11.1.0",
|
|
13
|
+
"helmet": "^6.0.0",
|
|
14
14
|
"vega": "^5.10.1",
|
|
15
15
|
"vega-lite": "^5.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@naturalcycles/dev-lib": "^
|
|
18
|
+
"@naturalcycles/dev-lib": "^13.6.0",
|
|
19
19
|
"@types/benchmark": "^2.1.0",
|
|
20
20
|
"@types/express": "^4.17.6",
|
|
21
|
-
"@types/node": "^
|
|
22
|
-
"fastify": "^
|
|
23
|
-
"jest": "^
|
|
21
|
+
"@types/node": "^18.7.20",
|
|
22
|
+
"fastify": "^4.6.0",
|
|
23
|
+
"jest": "^29.0.3"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist"
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"url": "https://github.com/NaturalCycles/bench-lib"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
38
|
+
"node": ">=16.10.0"
|
|
39
39
|
},
|
|
40
|
-
"version": "1.6.
|
|
40
|
+
"version": "1.6.2",
|
|
41
41
|
"description": "Benchmarking library, based on Benchmark.js and Autocannon",
|
|
42
42
|
"author": "Natural Cycles Team",
|
|
43
43
|
"license": "MIT"
|
package/CHANGELOG.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# [1.6.0](https://github.com/NaturalCycles/bench-lib/compare/v1.5.0...v1.6.0) (2021-10-25)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* runBenchScript, runCannonScript ([8a676e1](https://github.com/NaturalCycles/bench-lib/commit/8a676e18d84a7babbb64d066ff3009ad27ac63ea))
|
|
7
|
-
|
|
8
|
-
# [1.5.0](https://github.com/NaturalCycles/bench-lib/compare/v1.4.0...v1.5.0) (2021-08-25)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Features
|
|
12
|
-
|
|
13
|
-
* improvements ([9757eb9](https://github.com/NaturalCycles/bench-lib/commit/9757eb90c55fa8ec793d820de924dbbc82036c47))
|
|
14
|
-
|
|
15
|
-
# [1.4.0](https://github.com/NaturalCycles/bench-lib/compare/v1.3.0...v1.4.0) (2021-08-15)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Features
|
|
19
|
-
|
|
20
|
-
* allow to add a `path` to autocannon url ([2193343](https://github.com/NaturalCycles/bench-lib/commit/2193343c065a28dc1b4c335384824b26b2371e8a))
|
|
21
|
-
|
|
22
|
-
# [1.3.0](https://github.com/NaturalCycles/bench-lib/compare/v1.2.0...v1.3.0) (2021-08-15)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* writeRawSummary option (default to true) ([93c4b35](https://github.com/NaturalCycles/bench-lib/commit/93c4b35cf303e2d69c5130e9bd1e15f221a76143))
|
|
28
|
-
|
|
29
|
-
# [1.2.0](https://github.com/NaturalCycles/bench-lib/compare/v1.1.0...v1.2.0) (2021-08-15)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Features
|
|
33
|
-
|
|
34
|
-
* support autocannonOptions ([04f723b](https://github.com/NaturalCycles/bench-lib/commit/04f723b83ae8a14ba104e7f7b53d38f874579ac5))
|
|
35
|
-
|
|
36
|
-
# [1.1.0](https://github.com/NaturalCycles/bench-lib/compare/v1.0.7...v1.1.0) (2021-08-15)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Features
|
|
40
|
-
|
|
41
|
-
* runCannot options/improvements ([06f3653](https://github.com/NaturalCycles/bench-lib/commit/06f3653dbb2fc9daa515c59de582c07b4ee63a42))
|
|
42
|
-
|
|
43
|
-
## [1.0.7](https://github.com/NaturalCycles/bench-lib/compare/v1.0.6...v1.0.7) (2021-05-20)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### Bug Fixes
|
|
47
|
-
|
|
48
|
-
* deps, eslint ([f10baaf](https://github.com/NaturalCycles/bench-lib/commit/f10baaf8cbf30ba81ab36dad48f648969e0a08d3))
|
|
49
|
-
|
|
50
|
-
## [1.0.6](https://github.com/NaturalCycles/bench-lib/compare/v1.0.5...v1.0.6) (2021-02-26)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Bug Fixes
|
|
54
|
-
|
|
55
|
-
* deps ([61df76a](https://github.com/NaturalCycles/bench-lib/commit/61df76aeb0b915f1a68e42af5a48891fca0ef74f))
|
|
56
|
-
|
|
57
|
-
## [1.0.5](https://github.com/NaturalCycles/bench-lib/compare/v1.0.4...v1.0.5) (2020-12-12)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### Bug Fixes
|
|
61
|
-
|
|
62
|
-
* deps ([70f998c](https://github.com/NaturalCycles/bench-lib/commit/70f998cad1d2733738c11942c356ae188af8d609))
|
|
63
|
-
|
|
64
|
-
## [1.0.4](https://github.com/NaturalCycles/bench-lib/compare/v1.0.3...v1.0.4) (2020-12-08)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
### Bug Fixes
|
|
68
|
-
|
|
69
|
-
* modernize ([57c5f69](https://github.com/NaturalCycles/bench-lib/commit/57c5f69fbf96c96615356a985d9d94f6a89409a2))
|
|
70
|
-
|
|
71
|
-
## [1.0.3](https://github.com/NaturalCycles/bench-lib/compare/v1.0.2...v1.0.3) (2020-09-21)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### Bug Fixes
|
|
75
|
-
|
|
76
|
-
* deps ([c3c0e3d](https://github.com/NaturalCycles/bench-lib/commit/c3c0e3d39068f6f16516b4a5ab621b25721cc8f7))
|
|
77
|
-
|
|
78
|
-
## [1.0.2](https://github.com/NaturalCycles/bench-lib/compare/v1.0.1...v1.0.2) (2020-08-17)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
### Bug Fixes
|
|
82
|
-
|
|
83
|
-
* deps ([746e8e9](https://github.com/NaturalCycles/bench-lib/commit/746e8e92248a7967b42fbe81aabb88cb4db9c9fa))
|
|
84
|
-
|
|
85
|
-
## [1.0.1](https://github.com/NaturalCycles/bench-lib/compare/v1.0.0...v1.0.1) (2020-08-10)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
### Bug Fixes
|
|
89
|
-
|
|
90
|
-
* deps ([e949d93](https://github.com/NaturalCycles/bench-lib/commit/e949d93e7ff438dd6dbbde3e4ee15ded1e7b1254))
|
|
91
|
-
|
|
92
|
-
# 1.0.0 (2020-04-25)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
### Features
|
|
96
|
-
|
|
97
|
-
* first version ([5dd6a07](https://github.com/NaturalCycles/bench-lib/commit/5dd6a072aefa8125589cc7e4203ddcaebc766a09))
|