@naturalcycles/bench-lib 3.1.0 → 4.0.0
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/asciiChart.util.js +13 -16
- package/dist/bench.model.js +1 -2
- package/dist/bench.profles.d.ts +1 -1
- package/dist/bench.profles.js +4 -9
- package/dist/bench.util.d.ts +1 -1
- package/dist/bench.util.js +15 -20
- package/dist/cannon.model.d.ts +3 -1
- package/dist/cannon.model.js +1 -2
- package/dist/cannon.profiles.d.ts +1 -1
- package/dist/cannon.profiles.js +22 -26
- package/dist/cannon.util.d.ts +2 -2
- package/dist/cannon.util.js +31 -23
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -9
- package/dist/vendor/asciichart.js +3 -7
- package/package.json +17 -13
package/dist/asciiChart.util.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.plotAsciiChart = plotAsciiChart;
|
|
4
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
|
-
const asciichart_1 = require("./vendor/asciichart");
|
|
1
|
+
import { _range } from '@naturalcycles/js-lib';
|
|
2
|
+
import { asciiColor, asciiPlot } from './vendor/asciichart.js';
|
|
6
3
|
const colors = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
asciiColor.blue,
|
|
5
|
+
asciiColor.green,
|
|
6
|
+
asciiColor.yellow,
|
|
7
|
+
asciiColor.red,
|
|
8
|
+
asciiColor.magenta,
|
|
9
|
+
asciiColor.lightcyan,
|
|
13
10
|
// undefined, // equivalent to default
|
|
14
11
|
];
|
|
15
|
-
function plotAsciiChart(results) {
|
|
12
|
+
export function plotAsciiChart(results) {
|
|
16
13
|
const series = [];
|
|
17
14
|
const resultsLen = Object.keys(results).length;
|
|
18
15
|
Object.values(results).forEach((result, i) => {
|
|
19
16
|
series.push([
|
|
20
|
-
...
|
|
17
|
+
..._range(5 + 5 * i).map(() => 0),
|
|
21
18
|
result,
|
|
22
|
-
...
|
|
19
|
+
..._range(3 + 5 * (resultsLen - i)).map(() => 0),
|
|
23
20
|
]);
|
|
24
21
|
});
|
|
25
|
-
let s =
|
|
22
|
+
let s = asciiPlot(series, {
|
|
26
23
|
colors,
|
|
27
24
|
offset: 2,
|
|
28
25
|
height: 10,
|
|
@@ -38,5 +35,5 @@ function plotAsciiChart(results) {
|
|
|
38
35
|
function colored(char, color) {
|
|
39
36
|
if (!color)
|
|
40
37
|
return char;
|
|
41
|
-
return color + char +
|
|
38
|
+
return color + char + asciiColor.reset;
|
|
42
39
|
}
|
package/dist/bench.model.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/bench.profles.d.ts
CHANGED
package/dist/bench.profles.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const benchNoopFn = () => { };
|
|
6
|
-
exports.benchNoopFn = benchNoopFn;
|
|
7
|
-
const benchRandomFn = () => {
|
|
8
|
-
const _ = (0, js_lib_1._randomInt)(1, 10);
|
|
1
|
+
import { _randomInt } from '@naturalcycles/js-lib';
|
|
2
|
+
export const benchNoopFn = () => { };
|
|
3
|
+
export const benchRandomFn = () => {
|
|
4
|
+
const _ = _randomInt(1, 10);
|
|
9
5
|
};
|
|
10
|
-
exports.benchRandomFn = benchRandomFn;
|
package/dist/bench.util.d.ts
CHANGED
package/dist/bench.util.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
|
-
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
8
|
-
const benchmark_1 = tslib_1.__importDefault(require("benchmark"));
|
|
9
|
-
const asciiChart_util_1 = require("./asciiChart.util");
|
|
1
|
+
import { _range, pDefer } from '@naturalcycles/js-lib';
|
|
2
|
+
import { dimGrey, fs2, runScript, yellow } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import Benchmark from 'benchmark';
|
|
4
|
+
import { plotAsciiChart } from './asciiChart.util.js';
|
|
10
5
|
/**
|
|
11
6
|
* Wraps `runBench` in `runScript` for convenience, so it can be run in top-level without `await`.
|
|
12
7
|
*/
|
|
13
|
-
function runBenchScript(opt) {
|
|
8
|
+
export function runBenchScript(opt) {
|
|
14
9
|
// fake timeout is needed to workaround `benchmark` process exiting too early when 2+ runs are used
|
|
15
10
|
const timeout = setTimeout(() => { }, 10000000);
|
|
16
|
-
|
|
11
|
+
runScript(async () => {
|
|
17
12
|
await runBench(opt);
|
|
18
13
|
clearTimeout(timeout);
|
|
19
14
|
});
|
|
@@ -21,12 +16,12 @@ function runBenchScript(opt) {
|
|
|
21
16
|
/**
|
|
22
17
|
* Only DeferredFunctions are allowed, because of: https://github.com/bestiejs/benchmark.js/issues/111
|
|
23
18
|
*/
|
|
24
|
-
async function runBench(opt) {
|
|
19
|
+
export async function runBench(opt) {
|
|
25
20
|
const { runs = 2, writeSummary = true, asciiPlot = true, name = 'runBench' } = opt;
|
|
26
21
|
const { reportDirPath = `./tmp/${name}` } = opt;
|
|
27
22
|
console.log(`running benchmark...\n\n`);
|
|
28
23
|
const results = [];
|
|
29
|
-
for (const run of
|
|
24
|
+
for (const run of _range(1, runs + 1)) {
|
|
30
25
|
results.push(await runBenchOnce(opt, run));
|
|
31
26
|
}
|
|
32
27
|
const avg = {};
|
|
@@ -43,10 +38,10 @@ async function runBench(opt) {
|
|
|
43
38
|
// names.forEach(name => {
|
|
44
39
|
// summary[name] = results.hz.map(map => map[name]!)
|
|
45
40
|
// })
|
|
46
|
-
|
|
41
|
+
fs2.ensureDir(reportDirPath);
|
|
47
42
|
const summaryJsonPath = `${reportDirPath}/${name}.json`;
|
|
48
|
-
|
|
49
|
-
console.log(`saved ${
|
|
43
|
+
fs2.writeJson(summaryJsonPath, avg, { spaces: 2 });
|
|
44
|
+
console.log(`saved ${dimGrey(summaryJsonPath)}`);
|
|
50
45
|
}
|
|
51
46
|
// Vega plots are currently disabled
|
|
52
47
|
// if (writePlot) {
|
|
@@ -61,20 +56,20 @@ async function runBench(opt) {
|
|
|
61
56
|
// console.log(`saved ${dimGrey(plotPath)}`)
|
|
62
57
|
// }
|
|
63
58
|
if (asciiPlot) {
|
|
64
|
-
console.log('\n' +
|
|
59
|
+
console.log('\n' + plotAsciiChart(avg));
|
|
65
60
|
}
|
|
66
61
|
return avg;
|
|
67
62
|
}
|
|
68
63
|
async function runBenchOnce(opt, run) {
|
|
69
|
-
const defer =
|
|
70
|
-
const suite = new
|
|
64
|
+
const defer = pDefer();
|
|
65
|
+
const suite = new Benchmark.Suite()
|
|
71
66
|
.on('cycle', (event) => {
|
|
72
67
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
73
68
|
console.log(String(event.target));
|
|
74
69
|
// console.log(event.target)
|
|
75
70
|
})
|
|
76
71
|
.on('complete', function () {
|
|
77
|
-
console.log(`Fastest in run ${
|
|
72
|
+
console.log(`Fastest in run ${yellow(run)} is ` + this.filter('fastest').map('name'));
|
|
78
73
|
// console.log(this[0].stats)
|
|
79
74
|
// console.log(this)
|
|
80
75
|
const results = {};
|
package/dist/cannon.model.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export interface RunCannonOptions {
|
|
|
120
120
|
export interface AutocannonSummary {
|
|
121
121
|
name: string;
|
|
122
122
|
rpsAvg: number;
|
|
123
|
-
latencyAvg
|
|
123
|
+
latencyAvg?: number;
|
|
124
124
|
latency50: number;
|
|
125
125
|
latency90: number;
|
|
126
126
|
latency99: number;
|
|
@@ -133,8 +133,10 @@ export interface AutocannonSummary {
|
|
|
133
133
|
export interface AutocannonResult {
|
|
134
134
|
requests: {
|
|
135
135
|
average: number;
|
|
136
|
+
p50: number;
|
|
136
137
|
[k: string]: number;
|
|
137
138
|
};
|
|
139
|
+
latencies: string;
|
|
138
140
|
latency: {
|
|
139
141
|
average: number;
|
|
140
142
|
p50: number;
|
package/dist/cannon.model.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/cannon.profiles.js
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.expressFunctionFactory = expressFunctionFactory;
|
|
5
|
-
exports.expressSyncFunctionFactory = expressSyncFunctionFactory;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
8
|
-
const bareNodeServerFactory = async () => {
|
|
9
|
-
return node_http_1.default.createServer((_req, res) => {
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
export const bareNodeServerFactory = async () => {
|
|
3
|
+
return http.createServer((_req, res) => {
|
|
10
4
|
res.setHeader('content-type', 'application/json; charset=utf-8');
|
|
11
5
|
res.end(JSON.stringify({ hello: 'world' }));
|
|
12
6
|
});
|
|
13
7
|
};
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const app =
|
|
8
|
+
export const bareExpressServerFactory = async () => {
|
|
9
|
+
const { default: express } = await import('express');
|
|
10
|
+
const app = express();
|
|
17
11
|
app.disable('etag');
|
|
18
12
|
app.disable('x-powered-by');
|
|
19
13
|
app.get('/', (_req, res) => res.json({ hello: 'world' }));
|
|
20
|
-
return
|
|
14
|
+
return http.createServer(app);
|
|
21
15
|
};
|
|
22
|
-
exports.bareExpressServerFactory = bareExpressServerFactory;
|
|
23
16
|
/**
|
|
24
17
|
* Based on: https://github.com/fastify/benchmarks/blob/master/benchmarks/express-with-middlewares.js
|
|
25
18
|
*/
|
|
26
|
-
const expressWithMiddlewaresServerFactory = async () => {
|
|
27
|
-
const
|
|
28
|
-
const helmet =
|
|
19
|
+
export const expressWithMiddlewaresServerFactory = async () => {
|
|
20
|
+
const { default: express } = await import('express');
|
|
21
|
+
const { default: helmet } = await import('helmet');
|
|
22
|
+
const { default: cors } = await import('cors');
|
|
23
|
+
const app = express();
|
|
29
24
|
app.disable('etag');
|
|
30
25
|
app.disable('x-powered-by');
|
|
31
|
-
app.use(
|
|
26
|
+
app.use(cors());
|
|
32
27
|
app.use(helmet.dnsPrefetchControl());
|
|
33
28
|
app.use(helmet.frameguard());
|
|
34
29
|
app.use(helmet.hidePoweredBy());
|
|
@@ -36,27 +31,28 @@ const expressWithMiddlewaresServerFactory = async () => {
|
|
|
36
31
|
app.use(helmet.ieNoOpen());
|
|
37
32
|
app.use(helmet.xssFilter());
|
|
38
33
|
app.get('/', (_req, res) => res.json({ hello: 'world' }));
|
|
39
|
-
return
|
|
34
|
+
return http.createServer(app);
|
|
40
35
|
};
|
|
41
|
-
exports.expressWithMiddlewaresServerFactory = expressWithMiddlewaresServerFactory;
|
|
42
36
|
/**
|
|
43
37
|
* It does await, because tests show no difference (even faster?!) in results between sync and async functions for express.
|
|
44
38
|
*/
|
|
45
|
-
function expressFunctionFactory(fn) {
|
|
39
|
+
export function expressFunctionFactory(fn) {
|
|
46
40
|
return async () => {
|
|
47
|
-
const
|
|
41
|
+
const { default: express } = await import('express');
|
|
42
|
+
const app = express();
|
|
48
43
|
app.disable('etag');
|
|
49
44
|
app.disable('x-powered-by');
|
|
50
45
|
app.get('/', async (_req, res) => res.json(await fn()));
|
|
51
|
-
return
|
|
46
|
+
return http.createServer(app);
|
|
52
47
|
};
|
|
53
48
|
}
|
|
54
|
-
function expressSyncFunctionFactory(fn) {
|
|
49
|
+
export function expressSyncFunctionFactory(fn) {
|
|
55
50
|
return async () => {
|
|
56
|
-
const
|
|
51
|
+
const { default: express } = await import('express');
|
|
52
|
+
const app = express();
|
|
57
53
|
app.disable('etag');
|
|
58
54
|
app.disable('x-powered-by');
|
|
59
55
|
app.get('/', (_req, res) => res.json(fn()));
|
|
60
|
-
return
|
|
56
|
+
return http.createServer(app);
|
|
61
57
|
};
|
|
62
58
|
}
|
package/dist/cannon.util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StringMap } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { AutocannonSummary, HttpServerFactory, RunCannonOptions } from './cannon.model';
|
|
1
|
+
import type { StringMap } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { AutocannonSummary, HttpServerFactory, RunCannonOptions } from './cannon.model.js';
|
|
3
3
|
/**
|
|
4
4
|
* Wraps `runBench` in `runScript` for convenience, so it can be run in top-level without `await`.
|
|
5
5
|
*/
|
package/dist/cannon.util.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.runCannon = runCannon;
|
|
5
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
|
-
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
1
|
+
import { _omit, _range, pDefer, pDelay } from '@naturalcycles/js-lib';
|
|
2
|
+
import { boldRed, dimGrey, fs2, runScript, yellow } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import hdr from 'hdr-histogram-js';
|
|
7
4
|
/**
|
|
8
5
|
* Wraps `runBench` in `runScript` for convenience, so it can be run in top-level without `await`.
|
|
9
6
|
*/
|
|
10
|
-
function runCannonScript(profiles, optInput = {}) {
|
|
7
|
+
export function runCannonScript(profiles, optInput = {}) {
|
|
11
8
|
// fake timeout is needed to workaround `benchmark` process exiting too early when 2+ runs are used
|
|
12
9
|
const timeout = setTimeout(() => { }, 10000000);
|
|
13
|
-
|
|
10
|
+
runScript(async () => {
|
|
14
11
|
await runCannon(profiles, optInput);
|
|
15
12
|
clearTimeout(timeout);
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
|
-
async function runCannon(profiles, optInput = {}) {
|
|
15
|
+
export async function runCannon(profiles, optInput = {}) {
|
|
19
16
|
const opt = {
|
|
20
17
|
name: 'Benchmark',
|
|
21
18
|
reportDirPath: `./tmp/${optInput.name || 'Benchmark'}`,
|
|
@@ -48,25 +45,25 @@ async function runCannon(profiles, optInput = {}) {
|
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
const { reportDirPath } = opt;
|
|
51
|
-
|
|
48
|
+
fs2.ensureDir(reportDirPath);
|
|
52
49
|
const resultByProfile = {};
|
|
53
50
|
const summaries = [];
|
|
54
51
|
for (const profileName of Object.keys(profiles)) {
|
|
55
52
|
resultByProfile[profileName] = await runCannonProfile(profileName, profiles[profileName], opt);
|
|
56
53
|
const summary = toSummary(profileName, resultByProfile[profileName]);
|
|
57
54
|
if (!opt.includeLatencyPercentiles) {
|
|
58
|
-
|
|
55
|
+
_omit(summary, ['latency90', 'latency99'], true);
|
|
59
56
|
}
|
|
60
57
|
summaries.push(summary);
|
|
61
58
|
}
|
|
62
59
|
console.table(summaries);
|
|
63
60
|
if (opt.writeSummary) {
|
|
64
61
|
const summaryJsonPath = `${reportDirPath}/${opt.name}.summary.json`;
|
|
65
|
-
|
|
66
|
-
console.log(`saved ${
|
|
62
|
+
fs2.writeJson(summaryJsonPath, summaries, { spaces: 2 });
|
|
63
|
+
console.log(`saved ${dimGrey(summaryJsonPath)}`);
|
|
67
64
|
}
|
|
68
65
|
if (opt.writeRawSummary) {
|
|
69
|
-
|
|
66
|
+
fs2.writeJson(`${reportDirPath}/${opt.name}.rawSummary.json`, resultByProfile, { spaces: 2 });
|
|
70
67
|
}
|
|
71
68
|
// if (opt.writePlots) {
|
|
72
69
|
// await writePlotFiles(opt, summaries)
|
|
@@ -75,15 +72,15 @@ async function runCannon(profiles, optInput = {}) {
|
|
|
75
72
|
}
|
|
76
73
|
async function runCannonProfile(profileName, serverFactory, opt) {
|
|
77
74
|
const { runs, connections, pipelining, duration, cooldown, host, renderProgressBar, renderResultsTable, renderLatencyTable, silent, } = opt;
|
|
78
|
-
const autocannon =
|
|
75
|
+
const { default: autocannon } = await import('autocannon');
|
|
79
76
|
const server = await serverFactory();
|
|
80
77
|
await new Promise(resolve => server.listen(0, resolve));
|
|
81
78
|
const { port } = server.address();
|
|
82
79
|
const url = `${host}:${port}${opt.path}`;
|
|
83
80
|
let finalResult = undefined;
|
|
84
|
-
for (const run of
|
|
85
|
-
console.log(`\n${
|
|
86
|
-
const doneDefer =
|
|
81
|
+
for (const run of _range(1, runs + 1)) {
|
|
82
|
+
console.log(`\n${boldRed('=== ' + profileName + ' ===')} run ${yellow(run)}/${yellow(runs)}\n`);
|
|
83
|
+
const doneDefer = pDefer();
|
|
87
84
|
const instance = autocannon({
|
|
88
85
|
url,
|
|
89
86
|
connections,
|
|
@@ -106,21 +103,32 @@ async function runCannonProfile(profileName, serverFactory, opt) {
|
|
|
106
103
|
});
|
|
107
104
|
finalResult = await doneDefer;
|
|
108
105
|
if (!silent)
|
|
109
|
-
console.log(
|
|
110
|
-
await
|
|
106
|
+
console.log(dimGrey(`cooldown ${yellow(cooldown)} seconds...`));
|
|
107
|
+
await pDelay(cooldown * 1000);
|
|
111
108
|
}
|
|
112
109
|
await new Promise(resolve => server.close(resolve));
|
|
110
|
+
// console.log({finalResult})
|
|
111
|
+
// for whatever weird reason, after moving to ESM, we got a base64 encoded string instead of
|
|
112
|
+
// a fine object. So, we have to decode it manually :(
|
|
113
|
+
if (typeof finalResult.latencies === 'string') {
|
|
114
|
+
finalResult.latency = hdr.decodeFromCompressedBase64(finalResult.latencies).summary;
|
|
115
|
+
finalResult.requests = hdr.decodeFromCompressedBase64(finalResult.requests)
|
|
116
|
+
.summary;
|
|
117
|
+
finalResult.throughput = hdr.decodeFromCompressedBase64(finalResult.throughput)
|
|
118
|
+
.summary;
|
|
119
|
+
}
|
|
113
120
|
return finalResult;
|
|
114
121
|
}
|
|
115
122
|
function toSummary(name, result) {
|
|
123
|
+
// console.log({result})
|
|
116
124
|
return {
|
|
117
125
|
name,
|
|
118
|
-
rpsAvg: result.requests.
|
|
119
|
-
latencyAvg: result.latency
|
|
126
|
+
rpsAvg: result.requests.p50,
|
|
127
|
+
// latencyAvg: result.latency?.average,
|
|
120
128
|
latency50: result.latency.p50,
|
|
121
129
|
latency90: result.latency.p90,
|
|
122
130
|
latency99: result.latency.p99,
|
|
123
|
-
throughputAvg: Number((result.throughput.
|
|
131
|
+
throughputAvg: Number((result.throughput.p50 / 1024 / 1024).toFixed(2)),
|
|
124
132
|
errors: result.errors,
|
|
125
133
|
timeouts: result.timeouts,
|
|
126
134
|
non2xx: result.non2xx,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './bench.model';
|
|
2
|
-
export * from './bench.profles';
|
|
3
|
-
export * from './bench.util';
|
|
4
|
-
export * from './cannon.model';
|
|
5
|
-
export * from './cannon.profiles';
|
|
6
|
-
export * from './cannon.util';
|
|
1
|
+
export * from './bench.model.js';
|
|
2
|
+
export * from './bench.profles.js';
|
|
3
|
+
export * from './bench.util.js';
|
|
4
|
+
export * from './cannon.model.js';
|
|
5
|
+
export * from './cannon.profiles.js';
|
|
6
|
+
export * from './cannon.util.js';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
tslib_1.__exportStar(require("./cannon.model"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./cannon.profiles"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./cannon.util"), exports);
|
|
1
|
+
export * from './bench.model.js';
|
|
2
|
+
export * from './bench.profles.js';
|
|
3
|
+
export * from './bench.util.js';
|
|
4
|
+
export * from './cannon.model.js';
|
|
5
|
+
export * from './cannon.profiles.js';
|
|
6
|
+
export * from './cannon.util.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
|
|
4
3
|
Completely based on:
|
|
@@ -8,11 +7,8 @@ Adapted for typescript.
|
|
|
8
7
|
|
|
9
8
|
Super-experimental!
|
|
10
9
|
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.asciiColor = void 0;
|
|
13
|
-
exports.asciiPlot = asciiPlot;
|
|
14
10
|
/* eslint-disable */
|
|
15
|
-
|
|
11
|
+
export const asciiColor = {
|
|
16
12
|
black: '\u001B[30m',
|
|
17
13
|
red: '\u001B[31m',
|
|
18
14
|
green: '\u001B[32m',
|
|
@@ -34,9 +30,9 @@ exports.asciiColor = {
|
|
|
34
30
|
};
|
|
35
31
|
function colored(char, color) {
|
|
36
32
|
// do not color it if color is not specified
|
|
37
|
-
return color === undefined ? char : color + char +
|
|
33
|
+
return color === undefined ? char : color + char + asciiColor.reset;
|
|
38
34
|
}
|
|
39
|
-
function asciiPlot(seriesInput, cfg = {}) {
|
|
35
|
+
export function asciiPlot(seriesInput, cfg = {}) {
|
|
40
36
|
// this function takes both one array and array of arrays
|
|
41
37
|
// if an array of numbers is passed it is transformed to
|
|
42
38
|
// an array of exactly one array with numbers
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/bench-lib",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"scripts": {
|
|
4
5
|
"prepare": "husky",
|
|
5
6
|
"build": "dev-lib build",
|
|
@@ -9,20 +10,23 @@
|
|
|
9
10
|
"lbt": "dev-lib lbt"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@naturalcycles/js-lib": "^14
|
|
13
|
-
"@naturalcycles/nodejs-lib": "^13
|
|
14
|
-
"autocannon": "^8
|
|
15
|
-
"benchmark": "^2
|
|
13
|
+
"@naturalcycles/js-lib": "^14",
|
|
14
|
+
"@naturalcycles/nodejs-lib": "^13",
|
|
15
|
+
"autocannon": "^8",
|
|
16
|
+
"benchmark": "^2"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@naturalcycles/dev-lib": "^
|
|
19
|
-
"@types/benchmark": "^2
|
|
20
|
-
"@types/
|
|
21
|
-
"@types/
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
19
|
+
"@naturalcycles/dev-lib": "^17",
|
|
20
|
+
"@types/benchmark": "^2",
|
|
21
|
+
"@types/cors": "^2",
|
|
22
|
+
"@types/express": "^5",
|
|
23
|
+
"@types/node": "^22",
|
|
24
|
+
"@vitest/coverage-v8": "^3",
|
|
25
|
+
"express": "^5",
|
|
26
|
+
"fastify": "^5",
|
|
27
|
+
"helmet": "^8",
|
|
28
|
+
"tsx": "^4",
|
|
29
|
+
"vitest": "^3"
|
|
26
30
|
},
|
|
27
31
|
"files": [
|
|
28
32
|
"dist"
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
"engines": {
|
|
40
44
|
"node": ">=22.10.0"
|
|
41
45
|
},
|
|
42
|
-
"version": "
|
|
46
|
+
"version": "4.0.0",
|
|
43
47
|
"description": "Benchmarking library, based on Benchmark.js and Autocannon",
|
|
44
48
|
"author": "Natural Cycles Team",
|
|
45
49
|
"license": "MIT"
|