@nestia/benchmark 14.0.0 → 14.0.2
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/README.md +1 -1
- package/lib/DynamicBenchmarker.d.ts +238 -8
- package/lib/DynamicBenchmarker.js +221 -64
- package/lib/DynamicBenchmarker.js.map +1 -1
- package/lib/IBenchmarkEvent.d.ts +19 -0
- package/lib/internal/DynamicBenchmarkReporter.d.ts +50 -1
- package/lib/internal/DynamicBenchmarkReporter.js +43 -18
- package/lib/internal/DynamicBenchmarkReporter.js.map +1 -1
- package/lib/internal/DynamicBenchmarkStatistics.d.ts +25 -0
- package/lib/internal/DynamicBenchmarkStatistics.js +51 -0
- package/lib/internal/DynamicBenchmarkStatistics.js.map +1 -0
- package/lib/internal/IBenchmarkMaster.d.ts +26 -0
- package/lib/internal/IBenchmarkServant.d.ts +19 -0
- package/package.json +4 -3
- package/src/DynamicBenchmarker.ts +395 -104
- package/src/IBenchmarkEvent.ts +24 -0
- package/src/internal/DynamicBenchmarkReporter.ts +71 -16
- package/src/internal/DynamicBenchmarkStatistics.ts +62 -0
- package/src/internal/IBenchmarkMaster.ts +27 -0
- package/src/internal/IBenchmarkServant.ts +19 -0
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.DynamicBenchmarkReporter = void 0;
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Renders a benchmark report as markdown.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The reporter formats one report into fixed sections (specifications, arguments, time, statistics, memory chart, endpoints, failures) using a fixed locale.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design A one-function namespace, internal to the package, that keeps presentation out of the benchmark logic.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The content is computed from the report and host facts; no numbers are hardcoded.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its single job.
|
|
11
|
+
*/
|
|
8
12
|
var DynamicBenchmarkReporter;
|
|
9
13
|
(function (DynamicBenchmarkReporter) {
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Renders the report as markdown.
|
|
16
|
+
*
|
|
17
|
+
* Numbers use the fixed `en-US` locale, so a report reads the same on every
|
|
18
|
+
* machine. Decimals are truncated, not rounded, to two places. The CPU model
|
|
19
|
+
* is `unknown` when the platform exposes no CPU information.
|
|
20
|
+
*
|
|
21
|
+
* Processing cost: Endpoint and failure ordering require comparison sorts,
|
|
22
|
+
* costing O(E log E); four memory series each scan M samples, and temporary
|
|
23
|
+
* rows and final text scale with displayed data. Sorting copies preserve the
|
|
24
|
+
* caller's endpoint order.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation Each table row is built from the same statistics record; `Math.trunc` on the value scaled by 100 truncates toward zero to two decimals, including negative elapsed values after a wall-clock adjustment. `en-US` fixes separators, and an absent CPU model is displayed as `unknown`.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design Small local helpers (`integer`, `format`, `row`, `line`) share the formatting rules inside one function, so one place decides how a number reads.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The report states only the report's measurements and supplied host facts; nothing describes an unmeasured backend server or changes foreign runtime methods.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the locale, the truncation, and the CPU fallback.
|
|
30
|
+
*/
|
|
31
|
+
DynamicBenchmarkReporter.markdown = (report, host) => {
|
|
32
|
+
var _a;
|
|
33
|
+
// one fixed locale, so a report reads the same on every machine
|
|
34
|
+
const integer = (value) => value.toLocaleString("en-US");
|
|
35
|
+
const format = (value) => value === null
|
|
36
|
+
? "N/A"
|
|
37
|
+
: (Math.trunc(value * 100) / 100).toLocaleString("en-US");
|
|
12
38
|
const head = () => [
|
|
13
39
|
"Type",
|
|
14
40
|
"Count",
|
|
@@ -22,8 +48,8 @@ var DynamicBenchmarkReporter;
|
|
|
22
48
|
new Array(7).fill("----").join("|");
|
|
23
49
|
const row = (title, s) => [
|
|
24
50
|
title,
|
|
25
|
-
s.count
|
|
26
|
-
s.success
|
|
51
|
+
integer(s.count),
|
|
52
|
+
integer(s.success),
|
|
27
53
|
format(s.mean),
|
|
28
54
|
format(s.stdev),
|
|
29
55
|
format(s.minimum),
|
|
@@ -35,18 +61,17 @@ var DynamicBenchmarkReporter;
|
|
|
35
61
|
"> Generated by [`@nestia/benchmark`](https://github.com/samchon/nestia)",
|
|
36
62
|
``,
|
|
37
63
|
` - Specifications`,
|
|
38
|
-
` - CPU: ${
|
|
39
|
-
` - RAM: ${Math.floor(
|
|
40
|
-
` - NodeJS Version: ${
|
|
41
|
-
` - Backend Server: 1 core / 1 thread`,
|
|
64
|
+
` - CPU: ${(_a = host.cpu) !== null && _a !== void 0 ? _a : "unknown"}`,
|
|
65
|
+
` - RAM: ${integer(Math.floor(host.memory / 1024 / 1024 / 1024))} GB`,
|
|
66
|
+
` - NodeJS Version: ${host.node}`,
|
|
42
67
|
` - Arguments`,
|
|
43
|
-
` - Count: ${report.count
|
|
44
|
-
` - Threads: ${report.threads
|
|
45
|
-
` - Simultaneous: ${report.simultaneous
|
|
68
|
+
` - Count: ${integer(report.count)}`,
|
|
69
|
+
` - Threads: ${integer(report.threads)}`,
|
|
70
|
+
` - Simultaneous: ${integer(report.simultaneous)}`,
|
|
46
71
|
` - Time`,
|
|
47
72
|
` - Start: ${report.started_at}`,
|
|
48
73
|
` - Complete: ${report.completed_at}`,
|
|
49
|
-
` - Elapsed: ${(new Date(report.completed_at).getTime() - new Date(report.started_at).getTime())
|
|
74
|
+
` - Elapsed: ${integer(new Date(report.completed_at).getTime() - new Date(report.started_at).getTime())} ms`,
|
|
50
75
|
``,
|
|
51
76
|
head(),
|
|
52
77
|
row("Total", report.statistics),
|
|
@@ -88,8 +113,8 @@ var DynamicBenchmarkReporter;
|
|
|
88
113
|
.map((e) => [
|
|
89
114
|
e.method,
|
|
90
115
|
e.path,
|
|
91
|
-
e.count
|
|
92
|
-
(e.count - e.success)
|
|
116
|
+
integer(e.count),
|
|
117
|
+
integer(e.count - e.success),
|
|
93
118
|
].join(" | ")),
|
|
94
119
|
].join("\n");
|
|
95
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicBenchmarkReporter.js","sourceRoot":"","sources":["../../src/internal/DynamicBenchmarkReporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DynamicBenchmarkReporter.js","sourceRoot":"","sources":["../../src/internal/DynamicBenchmarkReporter.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,IAAiB,wBAAwB,CAoJxC;AApJD,WAAiB,wBAAwB;IA2BvC;;;;;;;;;;;;;;;;OAgBG;IACU,iCAAQ,GAAG,CACtB,MAAkC,EAClC,IAAW,EACH,EAAE;;QACV,gEAAgE;QAChE,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,MAAM,GAAG,CAAC,KAAoB,EAAE,EAAE,CACtC,KAAK,KAAK,IAAI;YACZ,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC9D,MAAM,IAAI,GAAG,GAAG,EAAE,CAChB;YACE,MAAM;YACN,OAAO;YACP,SAAS;YACT,OAAO;YACP,QAAQ;YACR,SAAS;YACT,SAAS;SACV,CAAC,IAAI,CAAC,KAAK,CAAC;YACb,IAAI;YACJ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAA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AAI,EAAE,EAAE,QAAQ,CAAC,CACrD;YACH,EAAE;YACF,sBAAsB;YACtB,EAAE;YACF,aAAa;YACb,kCAAkC;YAClC,mCAAmC;YACnC,GAAG,MAAM,CAAC,SAAS;iBAChB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC;iBACpC,KAAK,EAAE;iBACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;iBACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT;gBACE,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,IAAI;gBACN,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;gBAChB,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC;aAC7B,CAAC,IAAI,CAAC,KAAK,CAAC,CACd;SACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC,CAAC;AACJ,CAAC,EApJgB,wBAAwB,aAAxB,wBAAwB,GAAxB,wBAAwB,QAoJxC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DynamicBenchmarker } from "../DynamicBenchmarker";
|
|
2
|
+
import type { IBenchmarkEvent } from "../IBenchmarkEvent";
|
|
3
|
+
/**
|
|
4
|
+
* Statistics of benchmarked events.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The success count uses one reduction without retaining a filtered event array, while mean, population standard deviation, minimum and maximum share one pass over event start/completion durations. Both operations are linear in the event population.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design One namespace with one exported function; the elapsed-time measures are a private helper of it.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The formulas are standard statistics without tuning to any benchmark result.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its single job.
|
|
10
|
+
*/
|
|
11
|
+
export declare namespace DynamicBenchmarkStatistics {
|
|
12
|
+
/**
|
|
13
|
+
* Summarizes events into counts and elapsed-time statistics.
|
|
14
|
+
*
|
|
15
|
+
* Durations are milliseconds. The empty set has `null` measures, and the
|
|
16
|
+
* standard deviation is the population deviation computed with Welford's
|
|
17
|
+
* update.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation Welford's update accumulates deviations from a running mean, avoiding the subtraction of nearly equal large squared averages that caused cancellation in constant durations. The variance divisor is the population count; floating-point arithmetic remains approximate rather than a claim of exact arithmetic for every possible input.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design One shared pass computes the elapsed measures, a separate reduction counts successes, and the empty elapsed population is answered before the loop.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The method is the recognized single-pass algorithm rather than a compensating clamp.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the unit, the empty-set convention, and the algorithm.
|
|
23
|
+
*/
|
|
24
|
+
const of: (events: IBenchmarkEvent[]) => DynamicBenchmarker.IReport.IStatistics;
|
|
25
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicBenchmarkStatistics = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Statistics of benchmarked events.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The success count uses one reduction without retaining a filtered event array, while mean, population standard deviation, minimum and maximum share one pass over event start/completion durations. Both operations are linear in the event population.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design One namespace with one exported function; the elapsed-time measures are a private helper of it.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The formulas are standard statistics without tuning to any benchmark result.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its single job.
|
|
11
|
+
*/
|
|
12
|
+
var DynamicBenchmarkStatistics;
|
|
13
|
+
(function (DynamicBenchmarkStatistics) {
|
|
14
|
+
/**
|
|
15
|
+
* Summarizes events into counts and elapsed-time statistics.
|
|
16
|
+
*
|
|
17
|
+
* Durations are milliseconds. The empty set has `null` measures, and the
|
|
18
|
+
* standard deviation is the population deviation computed with Welford's
|
|
19
|
+
* update.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation Welford's update accumulates deviations from a running mean, avoiding the subtraction of nearly equal large squared averages that caused cancellation in constant durations. The variance divisor is the population count; floating-point arithmetic remains approximate rather than a claim of exact arithmetic for every possible input.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One shared pass computes the elapsed measures, a separate reduction counts successes, and the empty elapsed population is answered before the loop.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The method is the recognized single-pass algorithm rather than a compensating clamp.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the unit, the empty-set convention, and the algorithm.
|
|
25
|
+
*/
|
|
26
|
+
DynamicBenchmarkStatistics.of = (events) => (Object.assign({ count: events.length, success: events.reduce((count, event) => count + Number(event.success), 0) }, elapsed(events)));
|
|
27
|
+
const elapsed = (events) => {
|
|
28
|
+
if (events.length === 0)
|
|
29
|
+
return { mean: null, stdev: null, minimum: null, maximum: null };
|
|
30
|
+
// Welford's single pass keeps the sum of squared deviations from the
|
|
31
|
+
// running mean, so it stays non-negative where the difference between the
|
|
32
|
+
// mean of squares and the squared mean cancels to a negative value and the
|
|
33
|
+
// square root returns NaN.
|
|
34
|
+
let count = 0;
|
|
35
|
+
let mean = 0;
|
|
36
|
+
let deviations = 0;
|
|
37
|
+
let minimum = Number.POSITIVE_INFINITY;
|
|
38
|
+
let maximum = Number.NEGATIVE_INFINITY;
|
|
39
|
+
for (const event of events) {
|
|
40
|
+
const value = new Date(event.completed_at).getTime() -
|
|
41
|
+
new Date(event.started_at).getTime();
|
|
42
|
+
const delta = value - mean;
|
|
43
|
+
mean += delta / ++count;
|
|
44
|
+
deviations += delta * (value - mean);
|
|
45
|
+
minimum = Math.min(minimum, value);
|
|
46
|
+
maximum = Math.max(maximum, value);
|
|
47
|
+
}
|
|
48
|
+
return { mean, stdev: Math.sqrt(deviations / count), minimum, maximum };
|
|
49
|
+
};
|
|
50
|
+
})(DynamicBenchmarkStatistics || (exports.DynamicBenchmarkStatistics = DynamicBenchmarkStatistics = {}));
|
|
51
|
+
//# sourceMappingURL=DynamicBenchmarkStatistics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicBenchmarkStatistics.js","sourceRoot":"","sources":["../../src/internal/DynamicBenchmarkStatistics.ts"],"names":[],"mappings":";;;AAGA;;;;;;;GAOG;AACH,IAAiB,0BAA0B,CAkD1C;AAlDD,WAAiB,0BAA0B;IACzC;;;;;;;;;;;OAWG;IACU,6BAAE,GAAG,CAChB,MAAyB,EACe,EAAE,CAAC,iBAC3C,KAAK,EAAE,MAAM,CAAC,MAAM,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IACvE,OAAO,CAAC,MAAM,CAAC,EAClB,CAAC;IAEH,MAAM,OAAO,GAAG,CACd,MAAyB,EAIzB,EAAE;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YACrB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACnE,qEAAqE;QACrE,0EAA0E;QAC1E,2EAA2E;QAC3E,2BAA2B;QAC3B,IAAI,KAAK,GAAW,CAAC,CAAC;QACtB,IAAI,IAAI,GAAW,CAAC,CAAC;QACrB,IAAI,UAAU,GAAW,CAAC,CAAC;QAC3B,IAAI,OAAO,GAAW,MAAM,CAAC,iBAAiB,CAAC;QAC/C,IAAI,OAAO,GAAW,MAAM,CAAC,iBAAiB,CAAC;QAC/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GACT,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;gBACtC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,KAAK,GAAW,KAAK,GAAG,IAAI,CAAC;YACnC,IAAI,IAAI,KAAK,GAAG,EAAE,KAAK,CAAC;YACxB,UAAU,IAAI,KAAK,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;YACrC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACnC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC1E,CAAC,CAAC;AACJ,CAAC,EAlDgB,0BAA0B,aAA1B,0BAA0B,GAA1B,0BAA0B,QAkD1C"}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operations a servant may call on the master through the worker
|
|
3
|
+
* connection.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/common.md#principled-implementation The interface lists the two calls the servant makes back to the master: whether to load a file and how many benchmark function invocations have completed.
|
|
6
|
+
* @evidence contracts/common.md#clear-and-simple-design Two members, one per callback, with no behavior in the type.
|
|
7
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is the RPC contract of the master, not a test-specific seam.
|
|
8
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states which side implements it.
|
|
9
|
+
*/
|
|
1
10
|
export interface IBenchmarkMaster {
|
|
11
|
+
/**
|
|
12
|
+
* Asks the master whether a benchmark file, by basename, may be imported.
|
|
13
|
+
*
|
|
14
|
+
* @evidence contracts/common.md#principled-implementation The servant asks before every import so the master's predicate decides which modules load.
|
|
15
|
+
* @evidence contracts/common.md#clear-and-simple-design One predicate over a file name.
|
|
16
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The answer is the caller's filter, not a fixed list.
|
|
17
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the argument and the meaning of the answer.
|
|
18
|
+
*/
|
|
2
19
|
filter: (file: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Reports the number of benchmark function invocations this servant has
|
|
22
|
+
* completed so far, independently of logged HTTP event count.
|
|
23
|
+
*
|
|
24
|
+
* @evidence contracts/common.md#principled-implementation A servant reports its own cumulative count, and the master sums the servants' counts.
|
|
25
|
+
* @evidence contracts/common.md#clear-and-simple-design One notification with one number.
|
|
26
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The count is measured by the servant, not estimated.
|
|
27
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states that the value is cumulative and per servant.
|
|
28
|
+
*/
|
|
3
29
|
progress: (current: number) => void;
|
|
4
30
|
}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { IBenchmarkEvent } from "../IBenchmarkEvent";
|
|
2
|
+
/**
|
|
3
|
+
* The operations the master may call on a servant through the worker
|
|
4
|
+
* connection.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The interface lists the one call the master makes: run a share of benchmark function invocations and return their logged HTTP events.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design One member, no behavior in the type.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is the RPC contract of the servant, not a test-specific seam.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states which side implements it.
|
|
10
|
+
*/
|
|
2
11
|
export interface IBenchmarkServant {
|
|
12
|
+
/**
|
|
13
|
+
* Runs the requested number of benchmark function invocations with the given
|
|
14
|
+
* simultaneous budget and returns every logged HTTP event. One invocation can
|
|
15
|
+
* log zero, one or several events.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation The master gives each servant its share of the count and of the simultaneous budget, and the servant returns the events for its share.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design One request-response operation with two numbers in and events out.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The servant runs what the master assigned, without adjusting the budget.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the arguments and the returned events.
|
|
21
|
+
*/
|
|
3
22
|
execute(props: {
|
|
4
23
|
count: number;
|
|
5
24
|
simultaneous: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/benchmark",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.2",
|
|
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": "^14.0.
|
|
33
|
+
"@nestia/fetcher": "^14.0.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^25.3.3",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rimraf lib && ttsc",
|
|
51
|
-
"dev": "rimraf lib && ttsc --watch"
|
|
51
|
+
"dev": "rimraf lib && ttsc --watch",
|
|
52
|
+
"evidence": "evidence"
|
|
52
53
|
},
|
|
53
54
|
"types": "lib/index.d.ts"
|
|
54
55
|
}
|