* Benchmarks plain serializer performance
()
| 124 | * Benchmarks plain serializer performance |
| 125 | */ |
| 126 | function benchmarkPlainSerializer () { |
| 127 | console.log("📊 Plain Serializer Benchmarks"); |
| 128 | console.log("-".repeat(40)); |
| 129 | |
| 130 | const plainSerializer = serializers.get("text/plain"); |
| 131 | const suite = new Benchmark.Suite(); |
| 132 | |
| 133 | suite |
| 134 | .add("Plain Serializer - Simple object", () => { |
| 135 | plainSerializer(testData.simple, null, 200); |
| 136 | }) |
| 137 | .add("Plain Serializer - Medium (100 users)", () => { |
| 138 | plainSerializer(testData.medium, null, 200); |
| 139 | }) |
| 140 | .add("Plain Serializer - Large (1000 items)", () => { |
| 141 | plainSerializer(testData.large, null, 200); |
| 142 | }) |
| 143 | .add("Plain Serializer - Array (500 items)", () => { |
| 144 | plainSerializer(testData.arrayData, null, 200); |
| 145 | }) |
| 146 | .add("Plain Serializer - Error with stack", () => { |
| 147 | plainSerializer(null, testErrors.complex, 500, true); |
| 148 | }) |
| 149 | .add("Plain Serializer - Error without stack", () => { |
| 150 | plainSerializer(null, testErrors.complex, 500, false); |
| 151 | }) |
| 152 | .add("Plain Serializer - String error", () => { |
| 153 | plainSerializer(null, testErrors.string, 400, false); |
| 154 | }) |
| 155 | .on("cycle", event => { |
| 156 | console.log(` ${String(event.target)}`); |
| 157 | }) |
| 158 | .on("complete", function () { |
| 159 | console.log(` Fastest: ${this.filter("fastest").map("name")}\n`); |
| 160 | }) |
| 161 | .run({ async: false }); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Benchmarks serializer comparison for different MIME types |