@nestia/benchmark 11.3.1 → 11.3.3
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.
|
@@ -64,13 +64,15 @@ export declare namespace DynamicBenchmarker {
|
|
|
64
64
|
/**
|
|
65
65
|
* Filter function.
|
|
66
66
|
*
|
|
67
|
-
* The filter function
|
|
68
|
-
*
|
|
67
|
+
* The filter function is called with the file name (basename) of each
|
|
68
|
+
* benchmark function module, not with the function name. When it returns
|
|
69
|
+
* `false`, the file would never be imported in the servant, so that every
|
|
70
|
+
* function defined in the file would never be executed either.
|
|
69
71
|
*
|
|
70
|
-
* @param name
|
|
72
|
+
* @param file File name (basename) of the benchmark functions
|
|
71
73
|
* @returns Whether to execute the function or not.
|
|
72
74
|
*/
|
|
73
|
-
filter?: (
|
|
75
|
+
filter?: (file: string) => boolean;
|
|
74
76
|
/**
|
|
75
77
|
* Progress callback function.
|
|
76
78
|
*
|
|
@@ -110,7 +112,9 @@ export declare namespace DynamicBenchmarker {
|
|
|
110
112
|
* Every prefixed function will be executed in the servant.
|
|
111
113
|
*
|
|
112
114
|
* In other words, if a function name doesn't start with the prefix, then it
|
|
113
|
-
* would never be executed.
|
|
115
|
+
* would never be executed. Also, when a file name (basename) does not start
|
|
116
|
+
* with the prefix, the file would never be imported either, so that every
|
|
117
|
+
* function defined in the file would never be executed.
|
|
114
118
|
*/
|
|
115
119
|
prefix: string;
|
|
116
120
|
/**
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,6 +47,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
48
|
exports.DynamicBenchmarker = void 0;
|
|
16
49
|
const fs_1 = __importDefault(require("fs"));
|
|
50
|
+
const path_1 = __importDefault(require("path"));
|
|
17
51
|
const tgrid_1 = require("tgrid");
|
|
18
52
|
const tstl_1 = require("tstl");
|
|
19
53
|
const DynamicBenchmarkReporter_1 = require("./internal/DynamicBenchmarkReporter");
|
|
@@ -187,6 +221,12 @@ var DynamicBenchmarker;
|
|
|
187
221
|
return entireEvents;
|
|
188
222
|
});
|
|
189
223
|
})(DynamicBenchmarker || (exports.DynamicBenchmarker = DynamicBenchmarker = {}));
|
|
224
|
+
const specifier = (location) => {
|
|
225
|
+
const relative = path_1.default.relative(__dirname, path_1.default.resolve(location))
|
|
226
|
+
.split(path_1.default.sep)
|
|
227
|
+
.join("/");
|
|
228
|
+
return `./${relative}`;
|
|
229
|
+
};
|
|
190
230
|
const iterate = (ctx) => (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
231
|
const directory = yield fs_1.default.promises.readdir(path);
|
|
192
232
|
for (const file of directory) {
|
|
@@ -195,14 +235,21 @@ const iterate = (ctx) => (path) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
195
235
|
if (stat.isDirectory() === true)
|
|
196
236
|
yield iterate(ctx)(location);
|
|
197
237
|
else if (file.endsWith(__filename.substr(-3)) === true) {
|
|
198
|
-
|
|
238
|
+
// GATE BY FILE NAME (PREFIX & FILTER), SO THAT EXCLUDED FILES ARE
|
|
239
|
+
// NEVER IMPORTED
|
|
240
|
+
if (file.startsWith(ctx.props.prefix) === false)
|
|
241
|
+
continue;
|
|
242
|
+
if ((yield ctx.driver.filter(file)) === false)
|
|
243
|
+
continue;
|
|
244
|
+
// POSIX relative specifier: works both as a native ESM dynamic import
|
|
245
|
+
// (module: nodenext) and as a downleveled require() (module: commonjs)
|
|
246
|
+
// on any OS.
|
|
247
|
+
const modulo = yield Promise.resolve(`${specifier(location)}`).then(s => __importStar(require(s)));
|
|
199
248
|
for (const [key, value] of Object.entries(modulo)) {
|
|
200
249
|
if (typeof value !== "function")
|
|
201
250
|
continue;
|
|
202
251
|
else if (key.startsWith(ctx.props.prefix) === false)
|
|
203
252
|
continue;
|
|
204
|
-
else if ((yield ctx.driver.filter(key)) === false)
|
|
205
|
-
continue;
|
|
206
253
|
ctx.collection.push({
|
|
207
254
|
key,
|
|
208
255
|
value: value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicBenchmarker.js","sourceRoot":"","sources":["../src/DynamicBenchmarker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DynamicBenchmarker.js","sourceRoot":"","sources":["../src/DynamicBenchmarker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAAoB;AACpB,gDAA4B;AAC5B,iCAA8D;AAC9D,+BAAgD;AAGhD,kFAA+E;AAI/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,IAAiB,kBAAkB,CAmUlC;AAnUD,WAAiB,kBAAkB;IAyIjC;;;;;;;;;;OAUG;IACU,yBAAM,GAAG,CAAO,KAAmB,EAAoB,EAAE;;QACpE,MAAM,SAAS,GAAa,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAIR,MAAM,OAAO,CAAC,GAAG,CACrB,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAO,CAAC,EAAE,CAAC,EAAE,EAAE;;YACrD,MAAM,SAAS,GAIX,IAAI,uBAAe,CACrB,IAAI,EACJ;gBACE,MAAM,EAAE,MAAA,KAAK,CAAC,MAAM,mCAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;gBACpC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE;oBACpB,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;oBACvB,IAAI,KAAK,CAAC,QAAQ;wBAChB,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC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AAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;YACtC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,IAAI,OAAO,CAAC;QAChB,KAAK,IAAI,OAAO,GAAG,OAAO,CAAC;QAC3B,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC;IACtB,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACvD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/benchmark",
|
|
3
|
-
"version": "11.3.
|
|
3
|
+
"version": "11.3.3",
|
|
4
4
|
"description": "NestJS Performance Benchmark Program",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"tgrid": "^1.2.1",
|
|
32
32
|
"tstl": "^3.0.0",
|
|
33
|
-
"@nestia/fetcher": "^11.3.
|
|
33
|
+
"@nestia/fetcher": "^11.3.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^25.3.3",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IConnection } from "@nestia/fetcher";
|
|
2
2
|
import fs from "fs";
|
|
3
|
+
import NodePath from "path";
|
|
3
4
|
import { Driver, WorkerConnector, WorkerServer } from "tgrid";
|
|
4
5
|
import { HashMap, hash, sleep_for } from "tstl";
|
|
5
6
|
|
|
@@ -74,13 +75,15 @@ export namespace DynamicBenchmarker {
|
|
|
74
75
|
/**
|
|
75
76
|
* Filter function.
|
|
76
77
|
*
|
|
77
|
-
* The filter function
|
|
78
|
-
*
|
|
78
|
+
* The filter function is called with the file name (basename) of each
|
|
79
|
+
* benchmark function module, not with the function name. When it returns
|
|
80
|
+
* `false`, the file would never be imported in the servant, so that every
|
|
81
|
+
* function defined in the file would never be executed either.
|
|
79
82
|
*
|
|
80
|
-
* @param name
|
|
83
|
+
* @param file File name (basename) of the benchmark functions
|
|
81
84
|
* @returns Whether to execute the function or not.
|
|
82
85
|
*/
|
|
83
|
-
filter?: (
|
|
86
|
+
filter?: (file: string) => boolean;
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
89
|
* Progress callback function.
|
|
@@ -126,7 +129,9 @@ export namespace DynamicBenchmarker {
|
|
|
126
129
|
* Every prefixed function will be executed in the servant.
|
|
127
130
|
*
|
|
128
131
|
* In other words, if a function name doesn't start with the prefix, then it
|
|
129
|
-
* would never be executed.
|
|
132
|
+
* would never be executed. Also, when a file name (basename) does not start
|
|
133
|
+
* with the prefix, the file would never be imported either, so that every
|
|
134
|
+
* function defined in the file would never be executed.
|
|
130
135
|
*/
|
|
131
136
|
prefix: string;
|
|
132
137
|
|
|
@@ -366,6 +371,16 @@ interface IFunction<Parameters extends any[]> {
|
|
|
366
371
|
value: (...args: Parameters) => Promise<void>;
|
|
367
372
|
}
|
|
368
373
|
|
|
374
|
+
const specifier = (location: string): string => {
|
|
375
|
+
const relative: string = NodePath.relative(
|
|
376
|
+
__dirname,
|
|
377
|
+
NodePath.resolve(location),
|
|
378
|
+
)
|
|
379
|
+
.split(NodePath.sep)
|
|
380
|
+
.join("/");
|
|
381
|
+
return `./${relative}`;
|
|
382
|
+
};
|
|
383
|
+
|
|
369
384
|
const iterate =
|
|
370
385
|
<Parameters extends any[]>(ctx: {
|
|
371
386
|
collection: IFunction<Parameters>[];
|
|
@@ -379,11 +394,17 @@ const iterate =
|
|
|
379
394
|
const stat: fs.Stats = await fs.promises.stat(location);
|
|
380
395
|
if (stat.isDirectory() === true) await iterate(ctx)(location);
|
|
381
396
|
else if (file.endsWith(__filename.substr(-3)) === true) {
|
|
382
|
-
|
|
397
|
+
// GATE BY FILE NAME (PREFIX & FILTER), SO THAT EXCLUDED FILES ARE
|
|
398
|
+
// NEVER IMPORTED
|
|
399
|
+
if (file.startsWith(ctx.props.prefix) === false) continue;
|
|
400
|
+
if ((await ctx.driver.filter(file)) === false) continue;
|
|
401
|
+
// POSIX relative specifier: works both as a native ESM dynamic import
|
|
402
|
+
// (module: nodenext) and as a downleveled require() (module: commonjs)
|
|
403
|
+
// on any OS.
|
|
404
|
+
const modulo = await import(specifier(location));
|
|
383
405
|
for (const [key, value] of Object.entries(modulo)) {
|
|
384
406
|
if (typeof value !== "function") continue;
|
|
385
407
|
else if (key.startsWith(ctx.props.prefix) === false) continue;
|
|
386
|
-
else if ((await ctx.driver.filter(key)) === false) continue;
|
|
387
408
|
ctx.collection.push({
|
|
388
409
|
key,
|
|
389
410
|
value: value as (...args: Parameters) => Promise<any>,
|