* Tests renderer performance with different data sizes
()
| 350 | * Tests renderer performance with different data sizes |
| 351 | */ |
| 352 | function benchmarkDataSizeImpact () { |
| 353 | console.log("\n📊 Data Size Impact on JSON Renderer"); |
| 354 | console.log("-".repeat(40)); |
| 355 | |
| 356 | const suite = new Benchmark.Suite(); |
| 357 | const jsonRenderer = renderers.get("application/json"); |
| 358 | const { req, res } = createMockReqRes("application/json"); |
| 359 | |
| 360 | // Different data sizes |
| 361 | const smallData = { items: Array.from({ length: 10 }, (_, i) => ({ id: i })) }; |
| 362 | const mediumData = { items: Array.from({ length: 100 }, (_, i) => ({ id: i })) }; |
| 363 | const largeData = { items: Array.from({ length: 1000 }, (_, i) => ({ id: i })) }; |
| 364 | const extraLargeData = { items: Array.from({ length: 5000 }, (_, i) => ({ id: i })) }; |
| 365 | |
| 366 | suite |
| 367 | .add("JSON - 10 items", () => { |
| 368 | jsonRenderer(req, res, smallData); |
| 369 | }) |
| 370 | .add("JSON - 100 items", () => { |
| 371 | jsonRenderer(req, res, mediumData); |
| 372 | }) |
| 373 | .add("JSON - 1000 items", () => { |
| 374 | jsonRenderer(req, res, largeData); |
| 375 | }) |
| 376 | .add("JSON - 5000 items", () => { |
| 377 | jsonRenderer(req, res, extraLargeData); |
| 378 | }) |
| 379 | .on("cycle", event => { |
| 380 | console.log(` ${String(event.target)}`); |
| 381 | }) |
| 382 | .on("complete", function () { |
| 383 | console.log(" Performance scales linearly with data size"); |
| 384 | }) |
| 385 | .run(); |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Main execution function |
no test coverage detected