@nestia/e2e 0.6.0-dev.20240620-4 → 0.7.0-dev.20240709
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/lib/DynamicExecutor.d.ts +42 -34
- package/lib/DynamicExecutor.js +51 -81
- package/lib/DynamicExecutor.js.map +1 -1
- package/lib/GaffComparator.js +2 -6
- package/lib/GaffComparator.js.map +1 -1
- package/lib/RandomGenerator.js +21 -18
- package/lib/RandomGenerator.js.map +1 -1
- package/lib/TestValidator.d.ts +1 -1
- package/lib/TestValidator.js +7 -2
- package/lib/TestValidator.js.map +1 -1
- package/lib/module.d.ts +0 -2
- package/lib/module.js +0 -2
- package/lib/module.js.map +1 -1
- package/package.json +52 -59
- package/src/DynamicExecutor.ts +71 -87
- package/src/GaffComparator.ts +5 -10
- package/src/RandomGenerator.ts +7 -6
- package/src/TestValidator.ts +7 -3
- package/src/module.ts +0 -2
- package/lib/DynamicBenchmarker.d.ts +0 -176
- package/lib/DynamicBenchmarker.js +0 -577
- package/lib/DynamicBenchmarker.js.map +0 -1
- package/lib/StopWatch.d.ts +0 -24
- package/lib/StopWatch.js +0 -89
- package/lib/StopWatch.js.map +0 -1
- package/lib/structures/IBenchmarkEvent.d.ts +0 -9
- package/lib/structures/IBenchmarkEvent.js +0 -3
- package/lib/structures/IBenchmarkEvent.js.map +0 -1
- package/lib/structures/IBenchmarkMaster.d.ts +0 -6
- package/lib/structures/IBenchmarkMaster.js +0 -3
- package/lib/structures/IBenchmarkMaster.js.map +0 -1
- package/lib/structures/IBenchmarkServant.d.ts +0 -7
- package/lib/structures/IBenchmarkServant.js +0 -3
- package/lib/structures/IBenchmarkServant.js.map +0 -1
- package/src/DynamicBenchmarker.ts +0 -486
- package/src/StopWatch.ts +0 -38
- package/src/structures/IBenchmarkEvent.ts +0 -10
- package/src/structures/IBenchmarkMaster.ts +0 -5
- package/src/structures/IBenchmarkServant.ts +0 -8
package/package.json
CHANGED
|
@@ -1,59 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nestia/e2e",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "E2E test utilify functions",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@typescript-eslint/
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"ts-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"!lib/test",
|
|
54
|
-
"!src/test",
|
|
55
|
-
"README.md",
|
|
56
|
-
"LICENSE",
|
|
57
|
-
"package.json"
|
|
58
|
-
]
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@nestia/e2e",
|
|
3
|
+
"version": "0.7.0-dev.20240709",
|
|
4
|
+
"description": "E2E test utilify functions",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "npm run build:main && npm run build:test",
|
|
8
|
+
"build:main": "rimraf lib && tsc",
|
|
9
|
+
"build:test": "rimraf bin && tsc -p test/tsconfig.json",
|
|
10
|
+
"dev": "npm run build:test -- --watch",
|
|
11
|
+
"eslint": "eslint src && eslint test",
|
|
12
|
+
"prepare": "ts-patch install && typia patch",
|
|
13
|
+
"test": "node bin/test"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/samchon/nestia"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"e2e",
|
|
21
|
+
"nestia",
|
|
22
|
+
"nestjs",
|
|
23
|
+
"test",
|
|
24
|
+
"tdd",
|
|
25
|
+
"utility"
|
|
26
|
+
],
|
|
27
|
+
"author": "Jeongho Nam",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/samchon/nestia/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://nestia.io",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
|
|
35
|
+
"@types/node": "^18.11.18",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
37
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
38
|
+
"rimraf": "^4.1.2",
|
|
39
|
+
"ts-node": "^10.9.1",
|
|
40
|
+
"ts-patch": "^3.2.1",
|
|
41
|
+
"typescript": "^5.5.3",
|
|
42
|
+
"typescript-transform-paths": "^3.4.7",
|
|
43
|
+
"typia": "^6.4.3"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"lib",
|
|
47
|
+
"src",
|
|
48
|
+
"README.md",
|
|
49
|
+
"LICENSE",
|
|
50
|
+
"package.json"
|
|
51
|
+
]
|
|
52
|
+
}
|
package/src/DynamicExecutor.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
1
|
import fs from "fs";
|
|
3
2
|
import NodePath from "path";
|
|
4
3
|
|
|
5
|
-
import { StopWatch } from "./StopWatch";
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* Dynamic Executor running prefixed functions.
|
|
9
6
|
*
|
|
@@ -36,7 +33,7 @@ export namespace DynamicExecutor {
|
|
|
36
33
|
/**
|
|
37
34
|
* Options for dynamic executor.
|
|
38
35
|
*/
|
|
39
|
-
export interface
|
|
36
|
+
export interface IProps<Parameters extends any[], Ret = any> {
|
|
40
37
|
/**
|
|
41
38
|
* Prefix of function name.
|
|
42
39
|
*
|
|
@@ -46,6 +43,11 @@ export namespace DynamicExecutor {
|
|
|
46
43
|
*/
|
|
47
44
|
prefix: string;
|
|
48
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Location of the test functions.
|
|
48
|
+
*/
|
|
49
|
+
location: string;
|
|
50
|
+
|
|
49
51
|
/**
|
|
50
52
|
* Get parameters of a function.
|
|
51
53
|
*
|
|
@@ -54,6 +56,15 @@ export namespace DynamicExecutor {
|
|
|
54
56
|
*/
|
|
55
57
|
parameters: (name: string) => Parameters;
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* On complete function.
|
|
61
|
+
*
|
|
62
|
+
* Listener of completion of a test function.
|
|
63
|
+
*
|
|
64
|
+
* @param exec Execution result of a test function
|
|
65
|
+
*/
|
|
66
|
+
onComplete?: (exec: IExecution) => void;
|
|
67
|
+
|
|
57
68
|
/**
|
|
58
69
|
* Filter function whether to run or not.
|
|
59
70
|
*
|
|
@@ -80,13 +91,6 @@ export namespace DynamicExecutor {
|
|
|
80
91
|
paramters: Parameters,
|
|
81
92
|
) => Promise<any>;
|
|
82
93
|
|
|
83
|
-
/**
|
|
84
|
-
* Whether to show elapsed time on `console` or not.
|
|
85
|
-
*
|
|
86
|
-
* @default true
|
|
87
|
-
*/
|
|
88
|
-
showElapsedTime?: boolean;
|
|
89
|
-
|
|
90
94
|
/**
|
|
91
95
|
* Extension of dynamic functions.
|
|
92
96
|
*
|
|
@@ -107,38 +111,42 @@ export namespace DynamicExecutor {
|
|
|
107
111
|
/**
|
|
108
112
|
* Execution results of dynamic functions.
|
|
109
113
|
*/
|
|
110
|
-
executions:
|
|
114
|
+
executions: IExecution[];
|
|
111
115
|
|
|
112
116
|
/**
|
|
113
117
|
* Total elapsed time.
|
|
114
118
|
*/
|
|
115
119
|
time: number;
|
|
116
120
|
}
|
|
117
|
-
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Execution of a test function.
|
|
124
|
+
*/
|
|
125
|
+
export interface IExecution {
|
|
118
126
|
/**
|
|
119
|
-
*
|
|
127
|
+
* Name of function.
|
|
120
128
|
*/
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Name of function.
|
|
124
|
-
*/
|
|
125
|
-
name: string;
|
|
129
|
+
name: string;
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Location path of the function.
|
|
133
|
+
*/
|
|
134
|
+
location: string;
|
|
131
135
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Error when occured.
|
|
138
|
+
*/
|
|
139
|
+
error: Error | null;
|
|
136
140
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Elapsed time.
|
|
143
|
+
*/
|
|
144
|
+
started_at: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Completion time.
|
|
148
|
+
*/
|
|
149
|
+
completed_at: string;
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
/**
|
|
@@ -148,18 +156,12 @@ export namespace DynamicExecutor {
|
|
|
148
156
|
* Otherwise, {@link validate} mode does not terminate when error occurs, but
|
|
149
157
|
* just archive the error log.
|
|
150
158
|
*
|
|
151
|
-
* @param
|
|
152
|
-
* @returns
|
|
159
|
+
* @param props Properties of dynamic execution
|
|
160
|
+
* @returns Report of dynamic test functions execution
|
|
153
161
|
*/
|
|
154
|
-
export const assert =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* Run dynamic executor.
|
|
158
|
-
*
|
|
159
|
-
* @param path Location of prefixed functions
|
|
160
|
-
*/
|
|
161
|
-
(path: string): Promise<IReport> =>
|
|
162
|
-
main(options)(true)(path);
|
|
162
|
+
export const assert = <Arguments extends any[]>(
|
|
163
|
+
props: IProps<Arguments>,
|
|
164
|
+
): Promise<IReport> => main(true)(props);
|
|
163
165
|
|
|
164
166
|
/**
|
|
165
167
|
* Prepare dynamic executor in loose mode.
|
|
@@ -168,33 +170,27 @@ export namespace DynamicExecutor {
|
|
|
168
170
|
* Instead, the error would be archived and returns as a list. Otherwise,
|
|
169
171
|
* {@link assert} mode terminates the program directly when error occurs.
|
|
170
172
|
*
|
|
171
|
-
* @param
|
|
172
|
-
* @returns
|
|
173
|
+
* @param props Properties of dynamic executor
|
|
174
|
+
* @returns Report of dynamic test functions execution
|
|
173
175
|
*/
|
|
174
|
-
export const validate =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
* Run dynamic executor.
|
|
178
|
-
*
|
|
179
|
-
* @param path Location of prefix functions
|
|
180
|
-
* @returns List of errors
|
|
181
|
-
*/
|
|
182
|
-
(path: string): Promise<IReport> =>
|
|
183
|
-
main(options)(false)(path);
|
|
176
|
+
export const validate = <Arguments extends any[]>(
|
|
177
|
+
props: IProps<Arguments>,
|
|
178
|
+
): Promise<IReport> => main(false)(props);
|
|
184
179
|
|
|
185
180
|
const main =
|
|
186
|
-
<Arguments extends any[]>(options: IOptions<Arguments>) =>
|
|
187
181
|
(assert: boolean) =>
|
|
188
|
-
async
|
|
182
|
+
async <Arguments extends any[]>(
|
|
183
|
+
props: IProps<Arguments>,
|
|
184
|
+
): Promise<IReport> => {
|
|
189
185
|
const report: IReport = {
|
|
190
|
-
location:
|
|
186
|
+
location: props.location,
|
|
191
187
|
time: Date.now(),
|
|
192
188
|
executions: [],
|
|
193
189
|
};
|
|
194
190
|
|
|
195
|
-
const executor = execute(
|
|
196
|
-
const iterator = iterate(
|
|
197
|
-
await iterator(
|
|
191
|
+
const executor = execute(props)(report)(assert);
|
|
192
|
+
const iterator = iterate(props.extension ?? "js")(executor);
|
|
193
|
+
await iterator(props.location);
|
|
198
194
|
|
|
199
195
|
report.time = Date.now() - report.time;
|
|
200
196
|
return report;
|
|
@@ -224,54 +220,42 @@ export namespace DynamicExecutor {
|
|
|
224
220
|
};
|
|
225
221
|
|
|
226
222
|
const execute =
|
|
227
|
-
<Arguments extends any[]>(
|
|
223
|
+
<Arguments extends any[]>(props: IProps<Arguments>) =>
|
|
228
224
|
(report: IReport) =>
|
|
229
225
|
(assert: boolean) =>
|
|
230
226
|
async (location: string, modulo: Module<Arguments>): Promise<void> => {
|
|
231
227
|
for (const [key, closure] of Object.entries(modulo)) {
|
|
232
228
|
if (
|
|
233
|
-
key.substring(0,
|
|
229
|
+
key.substring(0, props.prefix.length) !== props.prefix ||
|
|
234
230
|
typeof closure !== "function" ||
|
|
235
|
-
(
|
|
231
|
+
(props.filter && props.filter(key) === false)
|
|
236
232
|
)
|
|
237
233
|
continue;
|
|
238
234
|
|
|
239
235
|
const func = async () => {
|
|
240
|
-
if (
|
|
241
|
-
await
|
|
242
|
-
else await closure(...
|
|
236
|
+
if (props.wrapper !== undefined)
|
|
237
|
+
await props.wrapper(key, closure, props.parameters(key));
|
|
238
|
+
else await closure(...props.parameters(key));
|
|
243
239
|
};
|
|
244
|
-
const label: string = chalk.greenBright(key);
|
|
245
240
|
|
|
246
|
-
const result:
|
|
241
|
+
const result: IExecution = {
|
|
247
242
|
name: key,
|
|
248
243
|
location,
|
|
249
244
|
error: null,
|
|
250
|
-
|
|
245
|
+
started_at: new Date().toISOString(),
|
|
246
|
+
completed_at: new Date().toISOString(),
|
|
251
247
|
};
|
|
252
248
|
report.executions.push(result);
|
|
253
249
|
|
|
254
250
|
try {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
result.time = Date.now() - result.time;
|
|
258
|
-
console.log(` - ${label}`);
|
|
259
|
-
} else {
|
|
260
|
-
result.time = (await StopWatch.measure(func))[1];
|
|
261
|
-
console.log(
|
|
262
|
-
` - ${label}: ${chalk.yellowBright(
|
|
263
|
-
result.time.toLocaleString(),
|
|
264
|
-
)} ms`,
|
|
265
|
-
);
|
|
266
|
-
}
|
|
251
|
+
await func();
|
|
252
|
+
result.completed_at = new Date().toISOString();
|
|
267
253
|
} catch (exp) {
|
|
268
|
-
result.time = Date.now() - result.time;
|
|
269
254
|
result.error = exp as Error;
|
|
270
|
-
|
|
271
|
-
console.log(
|
|
272
|
-
` - ${label} -> ${chalk.redBright((exp as Error)?.name)}`,
|
|
273
|
-
);
|
|
274
255
|
if (assert === true) throw exp;
|
|
256
|
+
} finally {
|
|
257
|
+
result.completed_at = new Date().toISOString();
|
|
258
|
+
if (props.onComplete) props.onComplete(result);
|
|
275
259
|
}
|
|
276
260
|
}
|
|
277
261
|
};
|
package/src/GaffComparator.ts
CHANGED
|
@@ -17,7 +17,7 @@ export namespace GaffComparator {
|
|
|
17
17
|
*/
|
|
18
18
|
export const strings =
|
|
19
19
|
<T>(getter: (input: T) => string | string[]) =>
|
|
20
|
-
(x: T, y: T) => {
|
|
20
|
+
(x: T, y: T): number => {
|
|
21
21
|
const a: string[] = wrap(getter(x));
|
|
22
22
|
const b: string[] = wrap(getter(y));
|
|
23
23
|
|
|
@@ -33,7 +33,7 @@ export namespace GaffComparator {
|
|
|
33
33
|
*/
|
|
34
34
|
export const dates =
|
|
35
35
|
<T>(getter: (input: T) => string | string[]) =>
|
|
36
|
-
(x: T, y: T) => {
|
|
36
|
+
(x: T, y: T): number => {
|
|
37
37
|
const take = (v: T) =>
|
|
38
38
|
wrap(getter(v)).map((str) => new Date(str).getTime());
|
|
39
39
|
const a: number[] = take(x);
|
|
@@ -51,7 +51,7 @@ export namespace GaffComparator {
|
|
|
51
51
|
*/
|
|
52
52
|
export const numbers =
|
|
53
53
|
<T>(closure: (input: T) => number | number[]) =>
|
|
54
|
-
(x: T, y: T) => {
|
|
54
|
+
(x: T, y: T): number => {
|
|
55
55
|
const a: number[] = wrap(closure(x));
|
|
56
56
|
const b: number[] = wrap(closure(y));
|
|
57
57
|
|
|
@@ -59,11 +59,6 @@ export namespace GaffComparator {
|
|
|
59
59
|
return idx !== -1 ? a[idx] - b[idx] : 0;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function wrap<T>(elem: T | T[]): T[] {
|
|
67
|
-
return Array.isArray(elem) ? elem : [elem];
|
|
68
|
-
}
|
|
62
|
+
const compare = (x: string, y: string) => x.localeCompare(y);
|
|
63
|
+
const wrap = <T>(elem: T | T[]): T[] => (Array.isArray(elem) ? elem : [elem]);
|
|
69
64
|
}
|
package/src/RandomGenerator.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { back_inserter, randint } from "tstl";
|
|
2
|
-
import { ranges } from "tstl";
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Random data generator.
|
|
6
3
|
*
|
|
@@ -146,9 +143,10 @@ export namespace RandomGenerator {
|
|
|
146
143
|
export const sample =
|
|
147
144
|
<T>(array: T[]) =>
|
|
148
145
|
(count: number): T[] => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
count = Math.min(count, array.length);
|
|
147
|
+
const indexes: Set<number> = new Set();
|
|
148
|
+
while (indexes.size < count) indexes.add(randint(0, array.length - 1));
|
|
149
|
+
return Array.from(indexes).map((index) => array[index]);
|
|
152
150
|
};
|
|
153
151
|
|
|
154
152
|
/**
|
|
@@ -159,3 +157,6 @@ export namespace RandomGenerator {
|
|
|
159
157
|
*/
|
|
160
158
|
export const pick = <T>(array: T[]): T => array[randint(0, array.length - 1)];
|
|
161
159
|
}
|
|
160
|
+
|
|
161
|
+
const randint = (min: number, max: number): number =>
|
|
162
|
+
Math.floor(Math.random() * (max - min + 1)) + min;
|
package/src/TestValidator.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ranges } from "tstl";
|
|
2
|
-
|
|
3
1
|
import { RandomGenerator } from "./RandomGenerator";
|
|
4
2
|
import { json_equal_to } from "./internal/json_equal_to";
|
|
5
3
|
|
|
@@ -304,7 +302,7 @@ export namespace TestValidator {
|
|
|
304
302
|
|
|
305
303
|
const reversed: typeof comp =
|
|
306
304
|
direction === "+" ? comp : (x, y) => comp(y, x);
|
|
307
|
-
if (
|
|
305
|
+
if (is_sorted(data, reversed) === false) {
|
|
308
306
|
if (
|
|
309
307
|
fields.length === 1 &&
|
|
310
308
|
data.length &&
|
|
@@ -341,3 +339,9 @@ function is_promise(input: any): input is Promise<any> {
|
|
|
341
339
|
typeof (input as any).catch === "function"
|
|
342
340
|
);
|
|
343
341
|
}
|
|
342
|
+
|
|
343
|
+
function is_sorted<T>(data: T[], comp: (x: T, y: T) => number): boolean {
|
|
344
|
+
for (let i: number = 1; i < data.length; ++i)
|
|
345
|
+
if (comp(data[i - 1], data[i]) > 0) return false;
|
|
346
|
+
return true;
|
|
347
|
+
}
|
package/src/module.ts
CHANGED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { IConnection } from "@nestia/fetcher";
|
|
2
|
-
import { WorkerServer } from "tgrid";
|
|
3
|
-
import { IBenchmarkMaster } from "./structures/IBenchmarkMaster";
|
|
4
|
-
import { IBenchmarkServant } from "./structures/IBenchmarkServant";
|
|
5
|
-
/**
|
|
6
|
-
* Dynamic benchmark executor running prefixed functions.
|
|
7
|
-
*
|
|
8
|
-
* `DynamicBenchmarker` is composed with two programs,
|
|
9
|
-
* {@link DynamicBenchmarker.master} and
|
|
10
|
-
* {@link DynamicBenchmarker.servant servants}. The master program creates
|
|
11
|
-
* multiple servant programs, and the servant programs execute the prefixed
|
|
12
|
-
* functions in parallel. When the pre-congirued count of requests are all
|
|
13
|
-
* completed, the master program collects the results and returns them.
|
|
14
|
-
*
|
|
15
|
-
* Therefore, when you want to benchmark the performance of a backend server,
|
|
16
|
-
* you have to make two programs; one for calling the
|
|
17
|
-
* {@link DynamicBenchmarker.master} function, and the other for calling the
|
|
18
|
-
* {@link DynamicBenchmarker.servant} function. Also, never forget to write
|
|
19
|
-
* the path of the servant program to the
|
|
20
|
-
* {@link DynamicBenchmarker.IMasterProps.servant} property.
|
|
21
|
-
*
|
|
22
|
-
* Also, you when you complete the benchmark execution through the
|
|
23
|
-
* {@link DynamicBenchmarker.master} and {@link DynamicBenchmarker.servant}
|
|
24
|
-
* functions, you can convert the result to markdown content by using the
|
|
25
|
-
* {@link DynamicBenchmarker.markdown} function.
|
|
26
|
-
*
|
|
27
|
-
* Additionally, if you hope to see some utilization cases,
|
|
28
|
-
* see the below example tagged links.
|
|
29
|
-
*
|
|
30
|
-
* @example https://github.com/samchon/nestia-start/blob/master/test/benchmaark/index.ts
|
|
31
|
-
* @example https://github.com/samchon/backend/blob/master/test/benchmark/index.ts
|
|
32
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
33
|
-
*/
|
|
34
|
-
export declare namespace DynamicBenchmarker {
|
|
35
|
-
/**
|
|
36
|
-
* Properties of the master program.
|
|
37
|
-
*/
|
|
38
|
-
interface IMasterProps {
|
|
39
|
-
/**
|
|
40
|
-
* Total count of the requests.
|
|
41
|
-
*/
|
|
42
|
-
count: number;
|
|
43
|
-
/**
|
|
44
|
-
* Number of threads.
|
|
45
|
-
*
|
|
46
|
-
* The number of threads to be executed as parallel servant.
|
|
47
|
-
*/
|
|
48
|
-
threads: number;
|
|
49
|
-
/**
|
|
50
|
-
* Number of simultaneous requests.
|
|
51
|
-
*
|
|
52
|
-
* The number of requests to be executed simultaneously.
|
|
53
|
-
*
|
|
54
|
-
* This property value would be divided by the {@link threads} in the servants.
|
|
55
|
-
*/
|
|
56
|
-
simultaneous: number;
|
|
57
|
-
/**
|
|
58
|
-
* Path of the servant program.
|
|
59
|
-
*
|
|
60
|
-
* The path of the servant program executing the
|
|
61
|
-
* {@link DynamicBenchmarker.servant} function.
|
|
62
|
-
*/
|
|
63
|
-
servant: string;
|
|
64
|
-
/**
|
|
65
|
-
* Filter function.
|
|
66
|
-
*
|
|
67
|
-
* The filter function to determine whether to execute the function in
|
|
68
|
-
* the servant or not.
|
|
69
|
-
*
|
|
70
|
-
* @param name Function name
|
|
71
|
-
* @returns Whether to execute the function or not.
|
|
72
|
-
*/
|
|
73
|
-
filter?: (name: string) => boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Progress callback function.
|
|
76
|
-
*
|
|
77
|
-
* @param complete The number of completed requests.
|
|
78
|
-
*/
|
|
79
|
-
progress?: (complete: number) => void;
|
|
80
|
-
/**
|
|
81
|
-
* Standard I/O option.
|
|
82
|
-
*
|
|
83
|
-
* The standard I/O option for the servant programs.
|
|
84
|
-
*/
|
|
85
|
-
stdio?: undefined | "overlapped" | "pipe" | "ignore" | "inherit";
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Properties of the servant progrma.
|
|
89
|
-
*/
|
|
90
|
-
interface IServantProps<Parameters extends any[]> {
|
|
91
|
-
/**
|
|
92
|
-
* Default connection.
|
|
93
|
-
*
|
|
94
|
-
* Default connection to be used in the servant.
|
|
95
|
-
*/
|
|
96
|
-
connection: IConnection;
|
|
97
|
-
/**
|
|
98
|
-
* Location of the benchmark functions.
|
|
99
|
-
*/
|
|
100
|
-
location: string;
|
|
101
|
-
/**
|
|
102
|
-
* Prefix of the benchmark functions.
|
|
103
|
-
*
|
|
104
|
-
* Every prefixed function will be executed in the servant.
|
|
105
|
-
*
|
|
106
|
-
* In other words, if a function name doesn't start with the prefix,
|
|
107
|
-
* then it would never be executed.
|
|
108
|
-
*/
|
|
109
|
-
prefix: string;
|
|
110
|
-
/**
|
|
111
|
-
* Get parameters of a function.
|
|
112
|
-
*
|
|
113
|
-
* When composing the parameters, never forget to copy the
|
|
114
|
-
* {@link IConnection.logger} property of default connection to the
|
|
115
|
-
* returning parameters.
|
|
116
|
-
*
|
|
117
|
-
* @param connection Default connection instance
|
|
118
|
-
* @param name Function name
|
|
119
|
-
*/
|
|
120
|
-
parameters: (connection: IConnection, name: string) => Parameters;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Benchmark report.
|
|
124
|
-
*/
|
|
125
|
-
interface IReport {
|
|
126
|
-
count: number;
|
|
127
|
-
threads: number;
|
|
128
|
-
simultaneous: number;
|
|
129
|
-
started_at: string;
|
|
130
|
-
completed_at: string;
|
|
131
|
-
statistics: IReport.IStatistics;
|
|
132
|
-
endpoints: Array<IReport.IEndpoint & IReport.IStatistics>;
|
|
133
|
-
}
|
|
134
|
-
namespace IReport {
|
|
135
|
-
interface IEndpoint {
|
|
136
|
-
method: string;
|
|
137
|
-
path: string;
|
|
138
|
-
}
|
|
139
|
-
interface IStatistics {
|
|
140
|
-
count: number;
|
|
141
|
-
success: number;
|
|
142
|
-
mean: number | null;
|
|
143
|
-
stdev: number | null;
|
|
144
|
-
minimum: number | null;
|
|
145
|
-
maximum: number | null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Master program.
|
|
150
|
-
*
|
|
151
|
-
* Creates a master program that executing the servant programs in parallel.
|
|
152
|
-
*
|
|
153
|
-
* Note that, {@link IMasterProps.servant} property must be the path of
|
|
154
|
-
* the servant program executing the {@link servant} function.
|
|
155
|
-
*
|
|
156
|
-
* @param props Properties of the master program
|
|
157
|
-
* @returns Benchmark report
|
|
158
|
-
*/
|
|
159
|
-
const master: (props: IMasterProps) => Promise<IReport>;
|
|
160
|
-
/**
|
|
161
|
-
* Create a servant program.
|
|
162
|
-
*
|
|
163
|
-
* Creates a servant program executing the prefixed functions in parallel.
|
|
164
|
-
*
|
|
165
|
-
* @param props Properties of the servant program
|
|
166
|
-
* @returns Servant program as a worker server
|
|
167
|
-
*/
|
|
168
|
-
const servant: <Parameters extends any[]>(props: IServantProps<Parameters>) => Promise<WorkerServer<null, IBenchmarkServant, IBenchmarkMaster>>;
|
|
169
|
-
/**
|
|
170
|
-
* Convert the benchmark report to markdown content.
|
|
171
|
-
*
|
|
172
|
-
* @param report Benchmark report
|
|
173
|
-
* @returns Markdown content
|
|
174
|
-
*/
|
|
175
|
-
const markdown: (report: DynamicBenchmarker.IReport) => string;
|
|
176
|
-
}
|