@aztec/end-to-end 0.0.1-commit.f504929 → 0.0.1-commit.f81dbcf
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/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +8 -2
- package/dest/e2e_epochs/epochs_test.d.ts +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +2 -1
- package/dest/e2e_fees/fees_test.d.ts +1 -1
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +8 -1
- package/dest/e2e_p2p/p2p_network.d.ts +2 -3
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +12 -16
- package/dest/e2e_p2p/shared.d.ts +1 -15
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +1 -24
- package/dest/fixtures/setup.d.ts +7 -3
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +2 -1
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +2 -3
- package/dest/shared/jest_setup.js +1 -41
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +9 -12
- package/dest/spartan/setup_test_wallets.d.ts +4 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +20 -8
- package/dest/spartan/tx_metrics.js +1 -1
- package/dest/spartan/utils/config.d.ts +1 -4
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +1 -2
- package/dest/spartan/utils/nodes.d.ts +5 -4
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +9 -9
- package/dest/test-wallet/test_wallet.js +1 -1
- package/package.json +44 -43
- package/src/bench/client_flows/client_flows_benchmark.ts +4 -2
- package/src/e2e_epochs/epochs_test.ts +1 -0
- package/src/e2e_fees/fees_test.ts +4 -1
- package/src/e2e_p2p/p2p_network.ts +18 -21
- package/src/e2e_p2p/shared.ts +1 -44
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/setup.ts +7 -2
- package/src/fixtures/token_utils.ts +1 -2
- package/src/shared/jest_setup.ts +1 -51
- package/src/shared/uniswap_l1_l2.ts +29 -24
- package/src/spartan/setup_test_wallets.ts +47 -17
- package/src/spartan/tx_metrics.ts +1 -1
- package/src/spartan/utils/config.ts +0 -1
- package/src/spartan/utils/nodes.ts +10 -15
- package/src/test-wallet/test_wallet.ts +1 -1
- package/dest/fixtures/elu_monitor.d.ts +0 -21
- package/dest/fixtures/elu_monitor.d.ts.map +0 -1
- package/dest/fixtures/elu_monitor.js +0 -102
- package/src/fixtures/elu_monitor.ts +0 -126
|
@@ -173,7 +173,7 @@ export async function withSequencersAdmin<T>(env: TestConfig, fn: (node: AztecNo
|
|
|
173
173
|
if (statusRes.status !== 200) {
|
|
174
174
|
throw new Error(`Admin endpoint returned status ${statusRes.status}`);
|
|
175
175
|
}
|
|
176
|
-
const client = createAztecNodeAdminClient(url
|
|
176
|
+
const client = createAztecNodeAdminClient(url);
|
|
177
177
|
return { result: await fn(client), process };
|
|
178
178
|
} catch (err) {
|
|
179
179
|
// Kill the port-forward before retrying
|
|
@@ -255,18 +255,21 @@ export async function initHADb(namespace: string): Promise<void> {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
258
|
+
* Enables or disables probabilistic transaction dropping on validators and waits for rollout.
|
|
259
|
+
* Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
|
|
260
260
|
*/
|
|
261
261
|
export async function setValidatorTxDrop({
|
|
262
262
|
namespace,
|
|
263
|
+
enabled,
|
|
263
264
|
probability,
|
|
264
265
|
logger: log,
|
|
265
266
|
}: {
|
|
266
267
|
namespace: string;
|
|
268
|
+
enabled: boolean;
|
|
267
269
|
probability: number;
|
|
268
270
|
logger: Logger;
|
|
269
271
|
}) {
|
|
272
|
+
const drop = enabled ? 'true' : 'false';
|
|
270
273
|
const prob = String(probability);
|
|
271
274
|
|
|
272
275
|
const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator'];
|
|
@@ -281,7 +284,7 @@ export async function setValidatorTxDrop({
|
|
|
281
284
|
if (names.length === 0) {
|
|
282
285
|
continue;
|
|
283
286
|
}
|
|
284
|
-
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
|
|
287
|
+
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
|
|
285
288
|
log.info(`command: ${cmd}`);
|
|
286
289
|
await execAsync(cmd);
|
|
287
290
|
updated = true;
|
|
@@ -363,24 +366,16 @@ export async function enableValidatorDynamicBootNode(
|
|
|
363
366
|
*/
|
|
364
367
|
export async function rollAztecPods(namespace: string, clearState: boolean = false) {
|
|
365
368
|
// Pod components use 'validator', but StatefulSets and PVCs use 'sequencer-node' for validators
|
|
366
|
-
// RPC nodes have nodeType='rpc-node' in Helm values, so their component label is 'rpc-node' (not 'rpc')
|
|
367
369
|
const podComponents = [
|
|
368
370
|
'p2p-bootstrap',
|
|
369
371
|
'prover-node',
|
|
370
372
|
'prover-broker',
|
|
371
373
|
'prover-agent',
|
|
372
374
|
'sequencer-node',
|
|
373
|
-
'rpc
|
|
374
|
-
'validator-ha-db',
|
|
375
|
-
];
|
|
376
|
-
const pvcComponents = [
|
|
377
|
-
'p2p-bootstrap',
|
|
378
|
-
'prover-node',
|
|
379
|
-
'prover-broker',
|
|
380
|
-
'sequencer-node',
|
|
381
|
-
'rpc-node',
|
|
375
|
+
'rpc',
|
|
382
376
|
'validator-ha-db',
|
|
383
377
|
];
|
|
378
|
+
const pvcComponents = ['p2p-bootstrap', 'prover-node', 'prover-broker', 'sequencer-node', 'rpc', 'validator-ha-db'];
|
|
384
379
|
// StatefulSet components that need to be scaled down before PVC deletion
|
|
385
380
|
// Note: validators use 'sequencer-node' as component label, not 'validator'
|
|
386
381
|
const statefulSetComponents = [
|
|
@@ -388,7 +383,7 @@ export async function rollAztecPods(namespace: string, clearState: boolean = fal
|
|
|
388
383
|
'prover-node',
|
|
389
384
|
'prover-broker',
|
|
390
385
|
'sequencer-node',
|
|
391
|
-
'rpc
|
|
386
|
+
'rpc',
|
|
392
387
|
'validator-ha-db',
|
|
393
388
|
];
|
|
394
389
|
|
|
@@ -275,7 +275,7 @@ export class TestWallet extends BaseWallet {
|
|
|
275
275
|
async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
|
|
276
276
|
const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
|
|
277
277
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
|
|
278
|
-
const txProvingResult = await this.pxe.proveTx(txRequest, this.
|
|
278
|
+
const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFor(opts.from));
|
|
279
279
|
return new ProvenTx(
|
|
280
280
|
this.aztecNode,
|
|
281
281
|
await txProvingResult.toTx(),
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */
|
|
2
|
-
export declare class EluMonitor {
|
|
3
|
-
private filePath;
|
|
4
|
-
private intervalMs;
|
|
5
|
-
private timer;
|
|
6
|
-
private lastELU;
|
|
7
|
-
private histogram;
|
|
8
|
-
private testName;
|
|
9
|
-
private testStart;
|
|
10
|
-
private eluSamples;
|
|
11
|
-
constructor(filePath: string, intervalMs?: number);
|
|
12
|
-
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */
|
|
13
|
-
startTest(testName: string): void;
|
|
14
|
-
/** Stop sampling and write a summary line. */
|
|
15
|
-
stopTest(): void;
|
|
16
|
-
/** Alias for stopTest — call on process exit to flush any remaining data. */
|
|
17
|
-
stop(): void;
|
|
18
|
-
private sample;
|
|
19
|
-
private writeSummary;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWx1X21vbml0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maXh0dXJlcy9lbHVfbW9uaXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxpSEFBaUg7QUFDakgscUJBQWEsVUFBVTtJQUNyQixPQUFPLENBQUMsUUFBUSxDQUFTO0lBQ3pCLE9BQU8sQ0FBQyxVQUFVLENBQVM7SUFDM0IsT0FBTyxDQUFDLEtBQUssQ0FBNkM7SUFDMUQsT0FBTyxDQUFDLE9BQU8sQ0FBbUM7SUFDbEQsT0FBTyxDQUFDLFNBQVMsQ0FBb0I7SUFDckMsT0FBTyxDQUFDLFFBQVEsQ0FBcUI7SUFDckMsT0FBTyxDQUFDLFNBQVMsQ0FBcUI7SUFDdEMsT0FBTyxDQUFDLFVBQVUsQ0FBZ0I7SUFFbEMsWUFBWSxRQUFRLEVBQUUsTUFBTSxFQUFFLFVBQVUsQ0FBQyxFQUFFLE1BQU0sRUFJaEQ7SUFFRCx1RkFBdUY7SUFDdkYsU0FBUyxDQUFDLFFBQVEsRUFBRSxNQUFNLEdBQUcsSUFBSSxDQW1CaEM7SUFFRCw4Q0FBOEM7SUFDOUMsUUFBUSxJQUFJLElBQUksQ0FtQmY7SUFFRCwrRUFBNkU7SUFDN0UsSUFBSSxJQUFJLElBQUksQ0FFWDtJQUVELE9BQU8sQ0FBQyxNQUFNO0lBOEJkLE9BQU8sQ0FBQyxZQUFZO0NBbUJyQiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elu_monitor.d.ts","sourceRoot":"","sources":["../../src/fixtures/elu_monitor.ts"],"names":[],"mappings":"AAKA,iHAAiH;AACjH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAA6C;IAC1D,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,UAAU,CAAgB;IAElC,YAAY,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAIhD;IAED,uFAAuF;IACvF,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAmBhC;IAED,8CAA8C;IAC9C,QAAQ,IAAI,IAAI,CAmBf;IAED,+EAA6E;IAC7E,IAAI,IAAI,IAAI,CAEX;IAED,OAAO,CAAC,MAAM;IA8Bd,OAAO,CAAC,YAAY;CAmBrB"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { appendFileSync } from 'node:fs';
|
|
2
|
-
import { monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
|
-
const NANOS_PER_MS = 1_000_000;
|
|
4
|
-
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */ export class EluMonitor {
|
|
5
|
-
filePath;
|
|
6
|
-
intervalMs;
|
|
7
|
-
timer;
|
|
8
|
-
lastELU;
|
|
9
|
-
histogram;
|
|
10
|
-
testName;
|
|
11
|
-
testStart;
|
|
12
|
-
eluSamples = [];
|
|
13
|
-
constructor(filePath, intervalMs){
|
|
14
|
-
this.filePath = filePath;
|
|
15
|
-
this.intervalMs = intervalMs ?? 2000;
|
|
16
|
-
this.histogram = monitorEventLoopDelay({
|
|
17
|
-
resolution: 20
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */ startTest(testName) {
|
|
21
|
-
this.stopTest();
|
|
22
|
-
this.testName = testName;
|
|
23
|
-
this.testStart = performance.now();
|
|
24
|
-
this.eluSamples = [];
|
|
25
|
-
appendFileSync(this.filePath, `\n=== Test: ${testName} ===\n`);
|
|
26
|
-
appendFileSync(this.filePath, padColumns('TIME', 'ELU', 'EL_DLY_P50', 'EL_DLY_P99', 'EL_DLY_MAX', 'HEAP_MB') + '\n');
|
|
27
|
-
this.lastELU = performance.eventLoopUtilization();
|
|
28
|
-
this.histogram.enable();
|
|
29
|
-
this.timer = setInterval(()=>this.sample(), this.intervalMs);
|
|
30
|
-
// Allow the process to exit even if the timer is still running.
|
|
31
|
-
this.timer.unref();
|
|
32
|
-
}
|
|
33
|
-
/** Stop sampling and write a summary line. */ stopTest() {
|
|
34
|
-
if (!this.timer) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// Take a final sample before stopping.
|
|
38
|
-
this.sample();
|
|
39
|
-
clearInterval(this.timer);
|
|
40
|
-
this.timer = undefined;
|
|
41
|
-
this.histogram.disable();
|
|
42
|
-
this.histogram.reset();
|
|
43
|
-
this.writeSummary();
|
|
44
|
-
this.lastELU = undefined;
|
|
45
|
-
this.testName = undefined;
|
|
46
|
-
this.testStart = undefined;
|
|
47
|
-
this.eluSamples = [];
|
|
48
|
-
}
|
|
49
|
-
/** Alias for stopTest — call on process exit to flush any remaining data. */ stop() {
|
|
50
|
-
this.stopTest();
|
|
51
|
-
}
|
|
52
|
-
sample() {
|
|
53
|
-
const newELU = performance.eventLoopUtilization();
|
|
54
|
-
const delta = performance.eventLoopUtilization(newELU, this.lastELU);
|
|
55
|
-
this.lastELU = newELU;
|
|
56
|
-
const elu = delta.utilization;
|
|
57
|
-
this.eluSamples.push(elu);
|
|
58
|
-
const p50 = this.histogram.percentile(50) / NANOS_PER_MS;
|
|
59
|
-
const p99 = this.histogram.percentile(99) / NANOS_PER_MS;
|
|
60
|
-
const max = this.histogram.max / NANOS_PER_MS;
|
|
61
|
-
const heapMb = Math.round(process.memoryUsage().heapUsed / (1024 * 1024));
|
|
62
|
-
const now = new Date();
|
|
63
|
-
const time = [
|
|
64
|
-
now.getHours(),
|
|
65
|
-
now.getMinutes(),
|
|
66
|
-
now.getSeconds()
|
|
67
|
-
].map((n)=>String(n).padStart(2, '0')).join(':');
|
|
68
|
-
const line = padColumns(time, elu.toFixed(2), `${p50.toFixed(1)}ms`, `${p99.toFixed(1)}ms`, `${max.toFixed(1)}ms`, String(heapMb));
|
|
69
|
-
appendFileSync(this.filePath, line + '\n');
|
|
70
|
-
// Reset histogram so next sample only reflects the new interval.
|
|
71
|
-
this.histogram.reset();
|
|
72
|
-
}
|
|
73
|
-
writeSummary() {
|
|
74
|
-
if (this.eluSamples.length === 0 || this.testStart === undefined) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const mean = this.eluSamples.reduce((a, b)=>a + b, 0) / this.eluSamples.length;
|
|
78
|
-
const maxElu = Math.max(...this.eluSamples);
|
|
79
|
-
const sorted = [
|
|
80
|
-
...this.eluSamples
|
|
81
|
-
].sort((a, b)=>a - b);
|
|
82
|
-
const p90Elu = sorted[Math.floor(sorted.length * 0.9)] ?? maxElu;
|
|
83
|
-
const durationS = ((performance.now() - this.testStart) / 1000).toFixed(1);
|
|
84
|
-
let summary = `--- Summary: mean_elu=${mean.toFixed(2)} max_elu=${maxElu.toFixed(2)} p90_elu=${p90Elu.toFixed(2)} duration=${durationS}s`;
|
|
85
|
-
if (maxElu > 0.85) {
|
|
86
|
-
summary += ' WARNING:ELU>0.85';
|
|
87
|
-
}
|
|
88
|
-
summary += ' ---\n';
|
|
89
|
-
appendFileSync(this.filePath, summary);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function padColumns(...cols) {
|
|
93
|
-
const widths = [
|
|
94
|
-
11,
|
|
95
|
-
7,
|
|
96
|
-
12,
|
|
97
|
-
12,
|
|
98
|
-
12,
|
|
99
|
-
8
|
|
100
|
-
];
|
|
101
|
-
return cols.map((col, i)=>col.padEnd(widths[i] ?? 10)).join('');
|
|
102
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { appendFileSync } from 'node:fs';
|
|
2
|
-
import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
|
-
|
|
4
|
-
const NANOS_PER_MS = 1_000_000;
|
|
5
|
-
|
|
6
|
-
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */
|
|
7
|
-
export class EluMonitor {
|
|
8
|
-
private filePath: string;
|
|
9
|
-
private intervalMs: number;
|
|
10
|
-
private timer: ReturnType<typeof setInterval> | undefined;
|
|
11
|
-
private lastELU: EventLoopUtilization | undefined;
|
|
12
|
-
private histogram: IntervalHistogram;
|
|
13
|
-
private testName: string | undefined;
|
|
14
|
-
private testStart: number | undefined;
|
|
15
|
-
private eluSamples: number[] = [];
|
|
16
|
-
|
|
17
|
-
constructor(filePath: string, intervalMs?: number) {
|
|
18
|
-
this.filePath = filePath;
|
|
19
|
-
this.intervalMs = intervalMs ?? 2000;
|
|
20
|
-
this.histogram = monitorEventLoopDelay({ resolution: 20 });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */
|
|
24
|
-
startTest(testName: string): void {
|
|
25
|
-
this.stopTest();
|
|
26
|
-
|
|
27
|
-
this.testName = testName;
|
|
28
|
-
this.testStart = performance.now();
|
|
29
|
-
this.eluSamples = [];
|
|
30
|
-
|
|
31
|
-
appendFileSync(this.filePath, `\n=== Test: ${testName} ===\n`);
|
|
32
|
-
appendFileSync(
|
|
33
|
-
this.filePath,
|
|
34
|
-
padColumns('TIME', 'ELU', 'EL_DLY_P50', 'EL_DLY_P99', 'EL_DLY_MAX', 'HEAP_MB') + '\n',
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
this.lastELU = performance.eventLoopUtilization();
|
|
38
|
-
this.histogram.enable();
|
|
39
|
-
|
|
40
|
-
this.timer = setInterval(() => this.sample(), this.intervalMs);
|
|
41
|
-
// Allow the process to exit even if the timer is still running.
|
|
42
|
-
this.timer.unref();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Stop sampling and write a summary line. */
|
|
46
|
-
stopTest(): void {
|
|
47
|
-
if (!this.timer) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Take a final sample before stopping.
|
|
52
|
-
this.sample();
|
|
53
|
-
|
|
54
|
-
clearInterval(this.timer);
|
|
55
|
-
this.timer = undefined;
|
|
56
|
-
this.histogram.disable();
|
|
57
|
-
this.histogram.reset();
|
|
58
|
-
|
|
59
|
-
this.writeSummary();
|
|
60
|
-
|
|
61
|
-
this.lastELU = undefined;
|
|
62
|
-
this.testName = undefined;
|
|
63
|
-
this.testStart = undefined;
|
|
64
|
-
this.eluSamples = [];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Alias for stopTest — call on process exit to flush any remaining data. */
|
|
68
|
-
stop(): void {
|
|
69
|
-
this.stopTest();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private sample(): void {
|
|
73
|
-
const newELU = performance.eventLoopUtilization();
|
|
74
|
-
const delta = performance.eventLoopUtilization(newELU, this.lastELU);
|
|
75
|
-
this.lastELU = newELU;
|
|
76
|
-
|
|
77
|
-
const elu = delta.utilization;
|
|
78
|
-
this.eluSamples.push(elu);
|
|
79
|
-
|
|
80
|
-
const p50 = this.histogram.percentile(50) / NANOS_PER_MS;
|
|
81
|
-
const p99 = this.histogram.percentile(99) / NANOS_PER_MS;
|
|
82
|
-
const max = this.histogram.max / NANOS_PER_MS;
|
|
83
|
-
const heapMb = Math.round(process.memoryUsage().heapUsed / (1024 * 1024));
|
|
84
|
-
|
|
85
|
-
const now = new Date();
|
|
86
|
-
const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(n => String(n).padStart(2, '0')).join(':');
|
|
87
|
-
|
|
88
|
-
const line = padColumns(
|
|
89
|
-
time,
|
|
90
|
-
elu.toFixed(2),
|
|
91
|
-
`${p50.toFixed(1)}ms`,
|
|
92
|
-
`${p99.toFixed(1)}ms`,
|
|
93
|
-
`${max.toFixed(1)}ms`,
|
|
94
|
-
String(heapMb),
|
|
95
|
-
);
|
|
96
|
-
appendFileSync(this.filePath, line + '\n');
|
|
97
|
-
|
|
98
|
-
// Reset histogram so next sample only reflects the new interval.
|
|
99
|
-
this.histogram.reset();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private writeSummary(): void {
|
|
103
|
-
if (this.eluSamples.length === 0 || this.testStart === undefined) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const mean = this.eluSamples.reduce((a, b) => a + b, 0) / this.eluSamples.length;
|
|
108
|
-
const maxElu = Math.max(...this.eluSamples);
|
|
109
|
-
const sorted = [...this.eluSamples].sort((a, b) => a - b);
|
|
110
|
-
const p90Elu = sorted[Math.floor(sorted.length * 0.9)] ?? maxElu;
|
|
111
|
-
const durationS = ((performance.now() - this.testStart) / 1000).toFixed(1);
|
|
112
|
-
|
|
113
|
-
let summary = `--- Summary: mean_elu=${mean.toFixed(2)} max_elu=${maxElu.toFixed(2)} p90_elu=${p90Elu.toFixed(2)} duration=${durationS}s`;
|
|
114
|
-
if (maxElu > 0.85) {
|
|
115
|
-
summary += ' WARNING:ELU>0.85';
|
|
116
|
-
}
|
|
117
|
-
summary += ' ---\n';
|
|
118
|
-
|
|
119
|
-
appendFileSync(this.filePath, summary);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function padColumns(...cols: string[]): string {
|
|
124
|
-
const widths = [11, 7, 12, 12, 12, 8];
|
|
125
|
-
return cols.map((col, i) => col.padEnd(widths[i] ?? 10)).join('');
|
|
126
|
-
}
|