Skip to content

Commit a8def52

Browse files
Reflexclaude
andcommitted
fix(loadtest): fix prettier formatting in load test scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7d4264b commit a8def52

4 files changed

Lines changed: 65 additions & 35 deletions

File tree

loadtest/h2-chaos.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ async function main() {
8585
});
8686

8787
const end = Date.now() + durationSec * 1000;
88-
let getOk = 0, getFail = 0, postOk = 0, postFail = 0;
88+
let getOk = 0,
89+
getFail = 0,
90+
postOk = 0,
91+
postFail = 0;
8992

9093
async function get() {
9194
try {
@@ -98,7 +101,10 @@ async function main() {
98101
}
99102
async function post() {
100103
try {
101-
const r = (await fetch(`https://localhost:${server.port}/x`, { method: 'POST', body: 'b' } as any)) as any;
104+
const r = (await fetch(`https://localhost:${server.port}/x`, {
105+
method: 'POST',
106+
body: 'b',
107+
} as any)) as any;
102108
await r.text();
103109
postOk++;
104110
} catch {
@@ -107,10 +113,7 @@ async function main() {
107113
}
108114

109115
while (Date.now() < end) {
110-
await Promise.all([
111-
...Array.from({ length: 10 }, get),
112-
...Array.from({ length: 5 }, post),
113-
]);
116+
await Promise.all([...Array.from({ length: 10 }, get), ...Array.from({ length: 5 }, post)]);
114117
}
115118

116119
await fetch.close();
@@ -119,11 +122,20 @@ async function main() {
119122
const getRate = getOk / (getOk + getFail);
120123
const postClean = postFail === 0 || postOk > 0;
121124

122-
console.log(JSON.stringify({
123-
getOk, getFail, getSuccessRate: Number(getRate.toFixed(3)),
124-
postOk, postFail,
125-
durationSec,
126-
}, null, 2));
125+
console.log(
126+
JSON.stringify(
127+
{
128+
getOk,
129+
getFail,
130+
getSuccessRate: Number(getRate.toFixed(3)),
131+
postOk,
132+
postFail,
133+
durationSec,
134+
},
135+
null,
136+
2,
137+
),
138+
);
127139

128140
if (getRate < 0.5) {
129141
console.error('GET success rate too low');

loadtest/h2-leak.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,22 @@ async function main() {
111111
const final = samples[samples.length - 1]?.heap ?? 0;
112112
const heapGrowthMB = (final - warmup) / (1024 * 1024);
113113

114-
console.log(JSON.stringify({
115-
durationSec,
116-
completed,
117-
failed,
118-
rps: Math.round(completed / durationSec),
119-
heapWarmupMB: Math.round(warmup / (1024 * 1024)),
120-
heapFinalMB: Math.round(final / (1024 * 1024)),
121-
heapGrowthMB: Math.round(heapGrowthMB),
122-
samples,
123-
}, null, 2));
114+
console.log(
115+
JSON.stringify(
116+
{
117+
durationSec,
118+
completed,
119+
failed,
120+
rps: Math.round(completed / durationSec),
121+
heapWarmupMB: Math.round(warmup / (1024 * 1024)),
122+
heapFinalMB: Math.round(final / (1024 * 1024)),
123+
heapGrowthMB: Math.round(heapGrowthMB),
124+
samples,
125+
},
126+
null,
127+
2,
128+
),
129+
);
124130

125131
if (heapGrowthMB > 50) {
126132
console.error(`HEAP GREW BY ${heapGrowthMB.toFixed(1)}MB — possible leak`);

loadtest/h2-multiplex.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,22 @@ async function main() {
8585
const totalMs = Number(process.hrtime.bigint() - t0) / 1e6;
8686

8787
latencies.sort((a, b) => a - b);
88-
console.log(JSON.stringify({
89-
N,
90-
failures,
91-
totalMs: Math.round(totalMs),
92-
rps: Math.round((N / totalMs) * 1000),
93-
p50_us: Math.round(percentile(latencies, 50)),
94-
p95_us: Math.round(percentile(latencies, 95)),
95-
p99_us: Math.round(percentile(latencies, 99)),
96-
max_us: Math.round(latencies[latencies.length - 1] ?? 0),
97-
}, null, 2));
88+
console.log(
89+
JSON.stringify(
90+
{
91+
N,
92+
failures,
93+
totalMs: Math.round(totalMs),
94+
rps: Math.round((N / totalMs) * 1000),
95+
p50_us: Math.round(percentile(latencies, 50)),
96+
p95_us: Math.round(percentile(latencies, 95)),
97+
p99_us: Math.round(percentile(latencies, 99)),
98+
max_us: Math.round(latencies[latencies.length - 1] ?? 0),
99+
},
100+
null,
101+
2,
102+
),
103+
);
98104

99105
await fetch.close();
100106
server.close();

loadtest/h2-pool-growth.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ async function main() {
100100
await fetch.close();
101101
server.close();
102102

103-
console.log(JSON.stringify({
104-
note: 'pool never shrinks today; peak == final is expected',
105-
samples: observations.length,
106-
}, null, 2));
103+
console.log(
104+
JSON.stringify(
105+
{
106+
note: 'pool never shrinks today; peak == final is expected',
107+
samples: observations.length,
108+
},
109+
null,
110+
2,
111+
),
112+
);
107113
}
108114

109115
main().catch((err) => {

0 commit comments

Comments
 (0)