@naturalcycles/bench-lib 2.0.0 → 2.1.1
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 +1 -1
- package/dist/cannon.profiles.js +11 -12
- package/package.json +4 -4
package/dist/bench.model.d.ts
CHANGED
package/dist/bench.util.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.runBenchScript = runBenchScript;
|
|
|
22
22
|
* Only DeferredFunctions are allowed, because of: https://github.com/bestiejs/benchmark.js/issues/111
|
|
23
23
|
*/
|
|
24
24
|
async function runBench(opt) {
|
|
25
|
-
const { runs =
|
|
25
|
+
const { runs = 2, writeSummary = true, asciiPlot = true, name = 'runBench' } = opt;
|
|
26
26
|
const { reportDirPath = `./tmp/${name}` } = opt;
|
|
27
27
|
console.log(`running benchmark...\n\n`);
|
|
28
28
|
const results = [];
|
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/package.json
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
"@naturalcycles/js-lib": "^14.0.0",
|
|
8
8
|
"@naturalcycles/nodejs-lib": "^13.0.2",
|
|
9
9
|
"autocannon": "^7.0.0",
|
|
10
|
-
"benchmark": "^2.1.4"
|
|
11
|
-
"express": "^4.17.1",
|
|
12
|
-
"helmet": "^7.0.0"
|
|
10
|
+
"benchmark": "^2.1.4"
|
|
13
11
|
},
|
|
14
12
|
"devDependencies": {
|
|
15
13
|
"@naturalcycles/dev-lib": "^13.6.0",
|
|
16
14
|
"@types/benchmark": "^2.1.0",
|
|
17
15
|
"@types/express": "^4.17.6",
|
|
18
16
|
"@types/node": "^20.1.0",
|
|
17
|
+
"express": "^4.17.1",
|
|
19
18
|
"fastify": "^4.6.0",
|
|
19
|
+
"helmet": "^7.0.0",
|
|
20
20
|
"jest": "^29.0.3"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=18.12.0"
|
|
36
36
|
},
|
|
37
|
-
"version": "2.
|
|
37
|
+
"version": "2.1.1",
|
|
38
38
|
"description": "Benchmarking library, based on Benchmark.js and Autocannon",
|
|
39
39
|
"author": "Natural Cycles Team",
|
|
40
40
|
"license": "MIT"
|