()
| 218 | } |
| 219 | |
| 220 | async function main() { |
| 221 | const options = parseArgs(process.argv.slice(2)); |
| 222 | const samples: MemorySample[] = []; |
| 223 | const startedAt = performance.now(); |
| 224 | const bootstrap = createLargeSplitStreamBootstrap({ |
| 225 | fileCount: options.fileCount, |
| 226 | linesPerFile: options.linesPerFile, |
| 227 | }); |
| 228 | console.log( |
| 229 | `navigation memory fixture files=${options.fileCount} lines=${options.linesPerFile} ` + |
| 230 | `navigations=${options.navigations} mode=${options.mode} gc=${options.gc ? "on" : "off"}`, |
| 231 | ); |
| 232 | samples.push(sampleMemory("after_bootstrap", 0, options)); |
| 233 | |
| 234 | const setup = await testRender(React.createElement(AppHost, { bootstrap }), { |
| 235 | width: options.width, |
| 236 | height: options.height, |
| 237 | }); |
| 238 | |
| 239 | try { |
| 240 | await renderOnce(setup); |
| 241 | samples.push(sampleMemory("after_first_frame", 0, options)); |
| 242 | console.log( |
| 243 | `navigation=${(0).toString().padStart(4)} heap=${formatBytes(samples.at(-1)!.heapUsedBytes)} ` + |
| 244 | `rss=${formatBytes(samples.at(-1)!.rssBytes)}`, |
| 245 | ); |
| 246 | |
| 247 | let position = 0; |
| 248 | let direction = 1; |
| 249 | for (let navigation = 1; navigation <= options.navigations; navigation += 1) { |
| 250 | const next = nextNavigationKey(position, direction, options); |
| 251 | position = next.position; |
| 252 | direction = next.direction; |
| 253 | await pressNavigationKey(setup, next.key); |
| 254 | |
| 255 | if (navigation % options.sampleEvery === 0 || navigation === options.navigations) { |
| 256 | const nextSample = sampleMemory("navigation", navigation, options); |
| 257 | samples.push(nextSample); |
| 258 | console.log( |
| 259 | `navigation=${navigation.toString().padStart(4)} heap=${formatBytes(nextSample.heapUsedBytes)} ` + |
| 260 | `rss=${formatBytes(nextSample.rssBytes)} external=${formatBytes(nextSample.externalBytes)}`, |
| 261 | ); |
| 262 | } |
| 263 | } |
| 264 | } finally { |
| 265 | await act(async () => { |
| 266 | setup.renderer.destroy(); |
| 267 | await Bun.sleep(0); |
| 268 | }); |
| 269 | samples.push(sampleMemory("after_destroy", options.navigations, options)); |
| 270 | } |
| 271 | |
| 272 | const navigationSamples = samples.filter( |
| 273 | (entry) => entry.label === "navigation" && entry.navigation >= options.warmupNavigations, |
| 274 | ); |
| 275 | const first = |
| 276 | navigationSamples[0] ?? samples.find((entry) => entry.label === "after_first_frame")!; |
| 277 | const last = navigationSamples.at(-1) ?? samples.at(-1)!; |
no test coverage detected