@samitouri / QOS-React-2 / commits / dcd4ec28a1

[Bench] Add JSON output and declare missing dependency (#37127)

Things I found while integrating this bench into https://github.com/vercel/next.js/pull/96234. See code. --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

dan committed Jul 26, 2026 at 10:55 UTC dcd4ec28a13268f758facecde6eea93e0e791388
4 files changed +143 -1
fixtures/flight-ssr-bench/bench-server.js
+23
@@ -18,6 +18,14 @@ const {
18 renderFlightFizzEdge,
19 } = require('./render-helpers');
20 const {printGrid} = require('./print-helpers');
21 +const fs = require('fs');
22 +const JSON_OUT = (function () {
23 + const arg = process.argv.find(function (a) {
24 + return a.startsWith('--json-out=');
25 + });
26 + return arg ? arg.slice('--json-out='.length) : null;
27 +})();
28 +const jsonResults = [];
29
30 // ---------------------------------------------------------------------------
31 // Build
@@ -275,6 +283,14 @@ async function main() {
283 const errors = data.errors + data.timeouts;
284
285 results[label] = {reqPerSec, latencyMedian, latencyP99};
286 + jsonResults.push({
287 + name: label,
288 + concurrency: c,
289 + reqPerSec,
290 + latencyMedian,
291 + latencyP99,
292 + errors,
293 + });
294
295 let line =
296 ' ' +
@@ -341,6 +357,13 @@ async function main() {
357 );
358 }
359
360 + if (JSON_OUT) {
361 + fs.writeFileSync(
362 + JSON_OUT,
363 + JSON.stringify({mode: 'server', results: jsonResults})
364 + );
365 + }
366 +
367 server.close();
368 }
369
fixtures/flight-ssr-bench/bench.js
+16
@@ -16,6 +16,17 @@ const {clientManifest, ssrManifest} = require('./webpack-mock');
16 const PROFILE_MODE = process.argv.includes('--profile');
17 const CONCURRENT_MODE = process.argv.includes('--concurrent');
18 const INJECT = !process.argv.includes('--no-injection');
19 +const JSON_OUT = (function () {
20 + const arg = process.argv.find(function (a) {
21 + return a.startsWith('--json-out=');
22 + });
23 + return arg ? arg.slice('--json-out='.length) : null;
24 +})();
25 +const jsonResults = [];
26 +function writeJsonOut(mode) {
27 + if (!JSON_OUT) return;
28 + fs.writeFileSync(JSON_OUT, JSON.stringify({mode, results: jsonResults}));
29 +}
30
31 // ---------------------------------------------------------------------------
32 // Build
@@ -174,6 +185,7 @@ async function runBenchmark(name, fn, iterations, warmup) {
185 }
186
187 function printResult(result) {
188 + jsonResults.push(result);
189 console.log(' %s:', result.name);
190 console.log(' Mean: %s ms', result.mean.toFixed(2));
191 console.log(' Median: %s ms', result.median.toFixed(2));
@@ -272,6 +284,7 @@ async function runConcurrent(name, fn, total, concurrency, warmup) {
284 }
285
286 function printConcurrentResult(result) {
287 + jsonResults.push(result);
288 console.log(' %s:', result.name);
289 console.log(' Req/s: %s', result.reqPerSec.toFixed(1));
290 console.log(' Mean: %s ms', result.mean.toFixed(2));
@@ -664,6 +677,7 @@ async function main() {
677 'higher is better'
678 );
679
680 + writeJsonOut('concurrent');
681 return;
682 }
683
@@ -768,6 +782,8 @@ async function main() {
782 'ms',
783 'median, lower is better'
784 );
785 +
786 + writeJsonOut(INJECT ? 'inject' : 'bare');
787 }
788
789 main().catch(function (err) {
fixtures/flight-ssr-bench/package.json
+2 -1
@@ -7,13 +7,14 @@
7 },
8 "dependencies": {
9 "@babel/core": "^7.16.0",
10 + "@babel/plugin-transform-modules-commonjs": "^7.25.9",
11 "@babel/preset-react": "^7.22.5",
12 "@babel/register": "^7.28.6",
13 + "autocannon": "^8.0.0",
14 "babel-loader": "^8.2.3",
15 "react": "experimental",
16 "react-dom": "experimental",
17 "react-server-dom-webpack": "experimental",
16 - "autocannon": "^8.0.0",
18 "webpack": "^5.64.4"
19 },
20 "scripts": {
fixtures/flight-ssr-bench/yarn.lock
+102
@@ -16,6 +16,15 @@
16 js-tokens "^4.0.0"
17 picocolors "^1.1.1"
18
19 +"@babel/code-frame@^7.29.7":
20 + version "7.29.7"
21 + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.29.7.tgz#f2fbbfea87c44a21590ec515b778b2c26d8866e7"
22 + integrity sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==
23 + dependencies:
24 + "@babel/helper-validator-identifier" "^7.29.7"
25 + js-tokens "^4.0.0"
26 + picocolors "^1.1.1"
27 +
28 "@babel/compat-data@^7.28.6":
29 version "7.29.0"
30 resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.29.0.tgz#00d03e8c0ac24dd9be942c5370990cbe1f17d88d"
@@ -53,6 +62,17 @@
62 "@jridgewell/trace-mapping" "^0.3.28"
63 jsesc "^3.0.2"
64
65 +"@babel/generator@^7.29.7":
66 + version "7.29.7"
67 + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.29.7.tgz#cca0b8827e6bcf3ba176788e7f3b180ad6db2fa3"
68 + integrity sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==
69 + dependencies:
70 + "@babel/parser" "^7.29.7"
71 + "@babel/types" "^7.29.7"
72 + "@jridgewell/gen-mapping" "^0.3.12"
73 + "@jridgewell/trace-mapping" "^0.3.28"
74 + jsesc "^3.0.2"
75 +
76 "@babel/helper-annotate-as-pure@^7.27.1", "@babel/helper-annotate-as-pure@^7.27.3":
77 version "7.27.3"
78 resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz#f31fd86b915fc4daf1f3ac6976c59be7084ed9c5"
@@ -76,6 +96,11 @@
96 resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.28.0.tgz#b9430df2aa4e17bc28665eadeae8aa1d985e6674"
97 integrity sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==
98
99 +"@babel/helper-globals@^7.29.7":
100 + version "7.29.7"
101 + resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.29.7.tgz#f04a96fbd8473241b1079243f5b3f03a3010ab7b"
102 + integrity sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==
103 +
104 "@babel/helper-module-imports@^7.28.6":
105 version "7.28.6"
106 resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz#60632cbd6ffb70b22823187201116762a03e2d5c"
@@ -84,6 +109,14 @@
109 "@babel/traverse" "^7.28.6"
110 "@babel/types" "^7.28.6"
111
112 +"@babel/helper-module-imports@^7.29.7":
113 + version "7.29.7"
114 + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz#ef25048a518e828d7393fac5882ddd73921d7396"
115 + integrity sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==
116 + dependencies:
117 + "@babel/traverse" "^7.29.7"
118 + "@babel/types" "^7.29.7"
119 +
120 "@babel/helper-module-transforms@^7.28.6":
121 version "7.28.6"
122 resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz#9312d9d9e56edc35aeb6e95c25d4106b50b9eb1e"
@@ -93,21 +126,45 @@
126 "@babel/helper-validator-identifier" "^7.28.5"
127 "@babel/traverse" "^7.28.6"
128
129 +"@babel/helper-module-transforms@^7.29.7":
130 + version "7.29.7"
131 + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz#b062747a5997ba138637201328bbff77960574ae"
132 + integrity sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==
133 + dependencies:
134 + "@babel/helper-module-imports" "^7.29.7"
135 + "@babel/helper-validator-identifier" "^7.29.7"
136 + "@babel/traverse" "^7.29.7"
137 +
138 "@babel/helper-plugin-utils@^7.27.1", "@babel/helper-plugin-utils@^7.28.6":
139 version "7.28.6"
140 resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz#6f13ea251b68c8532e985fd532f28741a8af9ac8"
141 integrity sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==
142
143 +"@babel/helper-plugin-utils@^7.29.7":
144 + version "7.29.7"
145 + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz#c0a0766f1a13617d8a17407d7ab8f9d486225ea4"
146 + integrity sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==
147 +
148 "@babel/helper-string-parser@^7.27.1":
149 version "7.27.1"
150 resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz#54da796097ab19ce67ed9f88b47bb2ec49367687"
151 integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==
152
153 +"@babel/helper-string-parser@^7.29.7":
154 + version "7.29.7"
155 + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz#7f0871d99824d23137d60f86fcf6130fd5a1b51f"
156 + integrity sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==
157 +
158 "@babel/helper-validator-identifier@^7.28.5":
159 version "7.28.5"
160 resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz#010b6938fab7cb7df74aa2bbc06aa503b8fe5fb4"
161 integrity sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==
162
163 +"@babel/helper-validator-identifier@^7.29.7":
164 + version "7.29.7"
165 + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz#bd87084ced0c796ec46bda492de6e83d29e89fc2"
166 + integrity sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==
167 +
168 "@babel/helper-validator-option@^7.27.1":
169 version "7.27.1"
170 resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f"
@@ -128,6 +185,13 @@
185 dependencies:
186 "@babel/types" "^7.29.0"
187
188 +"@babel/parser@^7.29.7":
189 + version "7.29.7"
190 + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.29.7.tgz#837b87387cbf5ec5530cb634b3c622f68edb9334"
191 + integrity sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==
192 + dependencies:
193 + "@babel/types" "^7.29.7"
194 +
195 "@babel/plugin-syntax-jsx@^7.28.6":
196 version "7.28.6"
197 resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.28.6.tgz#f8ca28bbd84883b5fea0e447c635b81ba73997ee"
@@ -135,6 +199,14 @@
199 dependencies:
200 "@babel/helper-plugin-utils" "^7.28.6"
201
202 +"@babel/plugin-transform-modules-commonjs@^7.25.9":
203 + version "7.29.7"
204 + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.29.7.tgz#70e6835abf2663dafbe94b8ef1f51de7351ef135"
205 + integrity sha512-j0vCldybPC5b5dwCQOJ21uKtHzt7hxLygJTg9eF1ScfaikEDNfzn94XoW5Fi+seBR0nCyL23xaBFFkq7dTM8XQ==
206 + dependencies:
207 + "@babel/helper-module-transforms" "^7.29.7"
208 + "@babel/helper-plugin-utils" "^7.29.7"
209 +
210 "@babel/plugin-transform-react-display-name@^7.28.0":
211 version "7.28.0"
212 resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.28.0.tgz#6f20a7295fea7df42eb42fed8f896813f5b934de"
@@ -200,6 +272,15 @@
272 "@babel/parser" "^7.28.6"
273 "@babel/types" "^7.28.6"
274
275 +"@babel/template@^7.29.7":
276 + version "7.29.7"
277 + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.29.7.tgz#4d9d4004f645cdd304de958c725162784ecac700"
278 + integrity sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==
279 + dependencies:
280 + "@babel/code-frame" "^7.29.7"
281 + "@babel/parser" "^7.29.7"
282 + "@babel/types" "^7.29.7"
283 +
284 "@babel/traverse@^7.28.6", "@babel/traverse@^7.29.0":
285 version "7.29.0"
286 resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.29.0.tgz#f323d05001440253eead3c9c858adbe00b90310a"
@@ -213,6 +294,19 @@
294 "@babel/types" "^7.29.0"
295 debug "^4.3.1"
296
297 +"@babel/traverse@^7.29.7":
298 + version "7.29.7"
299 + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.29.7.tgz#c47b07a41b95da0907d026b5dd894d98de7d2f2d"
300 + integrity sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==
301 + dependencies:
302 + "@babel/code-frame" "^7.29.7"
303 + "@babel/generator" "^7.29.7"
304 + "@babel/helper-globals" "^7.29.7"
305 + "@babel/parser" "^7.29.7"
306 + "@babel/template" "^7.29.7"
307 + "@babel/types" "^7.29.7"
308 + debug "^4.3.1"
309 +
310 "@babel/types@^7.27.3", "@babel/types@^7.28.6", "@babel/types@^7.29.0":
311 version "7.29.0"
312 resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.29.0.tgz#9f5b1e838c446e72cf3cd4b918152b8c605e37c7"
@@ -221,6 +315,14 @@
315 "@babel/helper-string-parser" "^7.27.1"
316 "@babel/helper-validator-identifier" "^7.28.5"
317
318 +"@babel/types@^7.29.7":
319 + version "7.29.7"
320 + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.29.7.tgz#8005e31d82712ee7adaef6e23c63b71a62770a92"
321 + integrity sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==
322 + dependencies:
323 + "@babel/helper-string-parser" "^7.29.7"
324 + "@babel/helper-validator-identifier" "^7.29.7"
325 +
326 "@colors/colors@1.5.0":
327 version "1.5.0"
328 resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"