@naturalcycles/bench-lib 2.1.0 → 3.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/bench.model.d.ts +3 -8
- package/dist/bench.profles.d.ts +3 -4
- package/dist/bench.profles.js +3 -9
- package/dist/bench.util.js +1 -1
- package/dist/cannon.profiles.js +11 -12
- package/dist/index.d.ts +6 -8
- package/dist/index.js +7 -14
- package/package.json +1 -1
package/dist/bench.model.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
resolve: () => void;
|
|
3
|
-
}
|
|
4
|
-
export type BenchDeferredFunction = (done: BenchDeferred) => any;
|
|
1
|
+
export type BenchFunction = () => void;
|
|
5
2
|
export interface RunBenchOptions {
|
|
6
3
|
/**
|
|
7
4
|
* Functions to benchmark.
|
|
8
|
-
* Record from function name to a `
|
|
9
|
-
* BenchDeferredFunction takes `done` callback as a first argument,
|
|
10
|
-
* `done.resolve()` HAS to be called at the end of your function.
|
|
5
|
+
* Record from function name to a `BenchFunction`.
|
|
11
6
|
*/
|
|
12
|
-
fns: Record<string,
|
|
7
|
+
fns: Record<string, BenchFunction>;
|
|
13
8
|
/**
|
|
14
9
|
* How many times to run.
|
|
15
10
|
* Every second run will be in reverse order.
|
package/dist/bench.profles.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const benchNoopFn:
|
|
3
|
-
export declare const benchRandomFn:
|
|
4
|
-
export declare const benchPDelayFn: BenchDeferredFunction;
|
|
1
|
+
import { BenchFunction } from './bench.model';
|
|
2
|
+
export declare const benchNoopFn: BenchFunction;
|
|
3
|
+
export declare const benchRandomFn: BenchFunction;
|
package/dist/bench.profles.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.benchRandomFn = exports.benchNoopFn = void 0;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
|
-
const benchNoopFn =
|
|
5
|
+
const benchNoopFn = () => { };
|
|
6
6
|
exports.benchNoopFn = benchNoopFn;
|
|
7
|
-
const benchRandomFn =
|
|
7
|
+
const benchRandomFn = () => {
|
|
8
8
|
const _ = (0, js_lib_1._randomInt)(1, 10);
|
|
9
|
-
done.resolve();
|
|
10
9
|
};
|
|
11
10
|
exports.benchRandomFn = benchRandomFn;
|
|
12
|
-
const benchPDelayFn = async (done) => {
|
|
13
|
-
await (0, js_lib_1.pDelay)();
|
|
14
|
-
done.resolve();
|
|
15
|
-
};
|
|
16
|
-
exports.benchPDelayFn = benchPDelayFn;
|
package/dist/bench.util.js
CHANGED
package/dist/cannon.profiles.js
CHANGED
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.expressSyncFunctionFactory = exports.expressFunctionFactory = exports.expressWithMiddlewaresServerFactory = exports.bareExpressServerFactory = exports.bareNodeServerFactory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
6
|
-
const express_1 = tslib_1.__importDefault(require("express"));
|
|
7
|
-
const helmet_1 = tslib_1.__importDefault(require("helmet"));
|
|
8
6
|
const bareNodeServerFactory = async () => {
|
|
9
7
|
return node_http_1.default.createServer((req, res) => {
|
|
10
8
|
res.setHeader('content-type', 'application/json; charset=utf-8');
|
|
@@ -13,7 +11,7 @@ const bareNodeServerFactory = async () => {
|
|
|
13
11
|
};
|
|
14
12
|
exports.bareNodeServerFactory = bareNodeServerFactory;
|
|
15
13
|
const bareExpressServerFactory = async () => {
|
|
16
|
-
const app = (
|
|
14
|
+
const app = require('express')();
|
|
17
15
|
app.disable('etag');
|
|
18
16
|
app.disable('x-powered-by');
|
|
19
17
|
app.get('/', (req, res) => res.json({ hello: 'world' }));
|
|
@@ -24,16 +22,17 @@ exports.bareExpressServerFactory = bareExpressServerFactory;
|
|
|
24
22
|
* Based on: https://github.com/fastify/benchmarks/blob/master/benchmarks/express-with-middlewares.js
|
|
25
23
|
*/
|
|
26
24
|
const expressWithMiddlewaresServerFactory = async () => {
|
|
27
|
-
const app = (
|
|
25
|
+
const app = require('express')();
|
|
26
|
+
const helmet = require('helmet');
|
|
28
27
|
app.disable('etag');
|
|
29
28
|
app.disable('x-powered-by');
|
|
30
29
|
app.use(require('cors')());
|
|
31
|
-
app.use(
|
|
32
|
-
app.use(
|
|
33
|
-
app.use(
|
|
34
|
-
app.use(
|
|
35
|
-
app.use(
|
|
36
|
-
app.use(
|
|
30
|
+
app.use(helmet.dnsPrefetchControl());
|
|
31
|
+
app.use(helmet.frameguard());
|
|
32
|
+
app.use(helmet.hidePoweredBy());
|
|
33
|
+
app.use(helmet.hsts());
|
|
34
|
+
app.use(helmet.ieNoOpen());
|
|
35
|
+
app.use(helmet.xssFilter());
|
|
37
36
|
app.get('/', (req, res) => res.json({ hello: 'world' }));
|
|
38
37
|
return node_http_1.default.createServer(app);
|
|
39
38
|
};
|
|
@@ -43,7 +42,7 @@ exports.expressWithMiddlewaresServerFactory = expressWithMiddlewaresServerFactor
|
|
|
43
42
|
*/
|
|
44
43
|
function expressFunctionFactory(fn) {
|
|
45
44
|
return async () => {
|
|
46
|
-
const app = (
|
|
45
|
+
const app = require('express')();
|
|
47
46
|
app.disable('etag');
|
|
48
47
|
app.disable('x-powered-by');
|
|
49
48
|
app.get('/', async (req, res) => res.json(await fn()));
|
|
@@ -53,7 +52,7 @@ function expressFunctionFactory(fn) {
|
|
|
53
52
|
exports.expressFunctionFactory = expressFunctionFactory;
|
|
54
53
|
function expressSyncFunctionFactory(fn) {
|
|
55
54
|
return async () => {
|
|
56
|
-
const app = (
|
|
55
|
+
const app = require('express')();
|
|
57
56
|
app.disable('etag');
|
|
58
57
|
app.disable('x-powered-by');
|
|
59
58
|
app.get('/', (req, res) => res.json(fn()));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type { RunBenchOptions, BenchDeferredFunction, HertzMap, HttpServerFactory, RunCannonOptions, AutocannonSummary, AutocannonResult, AutocannonOptions, };
|
|
8
|
-
export { runBenchScript, runBench, benchNoopFn, runCannon, runCannonScript, bareNodeServerFactory, bareExpressServerFactory, expressWithMiddlewaresServerFactory, expressFunctionFactory, };
|
|
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';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "bareExpressServerFactory", { enumerable: true, get: function () { return cannon_profiles_1.bareExpressServerFactory; } });
|
|
11
|
-
Object.defineProperty(exports, "bareNodeServerFactory", { enumerable: true, get: function () { return cannon_profiles_1.bareNodeServerFactory; } });
|
|
12
|
-
Object.defineProperty(exports, "expressFunctionFactory", { enumerable: true, get: function () { return cannon_profiles_1.expressFunctionFactory; } });
|
|
13
|
-
Object.defineProperty(exports, "expressWithMiddlewaresServerFactory", { enumerable: true, get: function () { return cannon_profiles_1.expressWithMiddlewaresServerFactory; } });
|
|
14
|
-
const cannon_util_1 = require("./cannon.util");
|
|
15
|
-
Object.defineProperty(exports, "runCannon", { enumerable: true, get: function () { return cannon_util_1.runCannon; } });
|
|
16
|
-
Object.defineProperty(exports, "runCannonScript", { enumerable: true, get: function () { return cannon_util_1.runCannonScript; } });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./bench.model"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./bench.profles"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./bench.util"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./cannon.model"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./cannon.profiles"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./cannon.util"), exports);
|