MCPcopy Create free account
hub / github.com/avoidwork/tenso / benchmarkStatusCodeHandling

Function benchmarkStatusCodeHandling

benchmarks/serializers.js:324–351  ·  view source on GitHub ↗

* Benchmarks status code handling

()

Source from the content-addressed store, hash-verified

322 * Benchmarks status code handling
323 */
324function benchmarkStatusCodeHandling () {
325 console.log("📊 Status Code Handling Performance");
326 console.log("-".repeat(40));
327
328 const customSerializer = serializers.get("application/json");
329 const suite = new Benchmark.Suite();
330
331 const statusCodes = [200, 201, 400, 404, 500];
332
333 for (const status of statusCodes) {
334 suite.add(`Custom - Status ${status}`, () => {
335 if (status >= 400) {
336 customSerializer(null, new Error(`Error ${status}`), status, false);
337 } else {
338 customSerializer(testData.simple, null, status);
339 }
340 });
341 }
342
343 suite
344 .on("cycle", event => {
345 console.log(` ${String(event.target)}`);
346 })
347 .on("complete", function () {
348 console.log(` Fastest: ${this.filter("fastest").map("name")}\n`);
349 })
350 .run({ async: false });
351}
352
353/**
354 * Main execution function

Callers 1

mainFunction · 0.85

Calls 1

logMethod · 0.80

Tested by

no test coverage detected