* Benchmarks data size impact on serialization performance
()
| 245 | * Benchmarks data size impact on serialization performance |
| 246 | */ |
| 247 | function benchmarkDataSizeImpact () { |
| 248 | console.log("📊 Data Size Impact on Serialization"); |
| 249 | console.log("-".repeat(40)); |
| 250 | |
| 251 | const customSerializer = serializers.get("application/json"); |
| 252 | const suite = new Benchmark.Suite(); |
| 253 | |
| 254 | // Generate different sized datasets |
| 255 | const sizes = [10, 100, 1000, 5000]; |
| 256 | |
| 257 | for (const size of sizes) { |
| 258 | const data = Array.from({ length: size }, (_, i) => ({ |
| 259 | id: i, |
| 260 | name: `Item ${i}`, |
| 261 | data: `Some data for item ${i}`, |
| 262 | timestamp: Date.now() |
| 263 | })); |
| 264 | |
| 265 | suite.add(`Custom Serializer - ${size} items`, () => { |
| 266 | customSerializer(data, null, 200); |
| 267 | }); |
| 268 | } |
| 269 | |
| 270 | suite |
| 271 | .on("cycle", event => { |
| 272 | console.log(` ${String(event.target)}`); |
| 273 | }) |
| 274 | .on("complete", function () { |
| 275 | console.log(" Performance scales linearly with data size\n"); |
| 276 | }) |
| 277 | .run({ async: false }); |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Tests serializer memory usage |