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

Function benchmarkCustomSerializer

benchmarks/serializers.js:85–121  ·  view source on GitHub ↗

* Benchmarks custom serializer performance

()

Source from the content-addressed store, hash-verified

83 * Benchmarks custom serializer performance
84 */
85function benchmarkCustomSerializer () {
86 console.log("📊 Custom Serializer Benchmarks");
87 console.log("-".repeat(40));
88
89 const customSerializer = serializers.get("application/json");
90 const suite = new Benchmark.Suite();
91
92 suite
93 .add("Custom Serializer - Simple object", () => {
94 customSerializer(testData.simple, null, 200);
95 })
96 .add("Custom Serializer - Medium (100 users)", () => {
97 customSerializer(testData.medium, null, 200);
98 })
99 .add("Custom Serializer - Large (1000 items)", () => {
100 customSerializer(testData.large, null, 200);
101 })
102 .add("Custom Serializer - Array (500 items)", () => {
103 customSerializer(testData.arrayData, null, 200);
104 })
105 .add("Custom Serializer - Error with stack", () => {
106 customSerializer(null, testErrors.complex, 500, true);
107 })
108 .add("Custom Serializer - Error without stack", () => {
109 customSerializer(null, testErrors.complex, 500, false);
110 })
111 .add("Custom Serializer - String error", () => {
112 customSerializer(null, testErrors.string, 400, false);
113 })
114 .on("cycle", event => {
115 console.log(` ${String(event.target)}`);
116 })
117 .on("complete", function () {
118 console.log(` Fastest: ${this.filter("fastest").map("name")}\n`);
119 })
120 .run({ async: false });
121}
122
123/**
124 * Benchmarks plain serializer performance

Callers 1

mainFunction · 0.85

Calls 1

logMethod · 0.80

Tested by

no test coverage detected