MCPcopy
hub / github.com/nestjs/nest / printComparison

Function printComparison

tools/benchmarks/src/main.ts:204–245  ·  view source on GitHub ↗
(
  baseName: string,
  base: BenchmarkSummary | undefined,
  nestName: string,
  nest: BenchmarkSummary | undefined,
)

Source from the content-addressed store, hash-verified

202}
203
204function printComparison(
205 baseName: string,
206 base: BenchmarkSummary | undefined,
207 nestName: string,
208 nest: BenchmarkSummary | undefined,
209): void {
210 // eslint-disable-next-line no-console
211 console.log(`\n--- Comparison: ${baseName} <-> ${nestName} ---`);
212
213 if (!base || !nest) {
214 // eslint-disable-next-line no-console
215 console.log(
216 `Missing results: ${baseName}=${base ? 'ok' : 'missing'} ${nestName}=${nest ? 'ok' : 'missing'}`,
217 );
218 return;
219 }
220
221 const rpsPct = pctChange(nest.requestsPerSecAvg, base.requestsPerSecAvg);
222 const latAvgPct = pctChange(nest.latencyAvgMs, base.latencyAvgMs);
223 const latP99Pct = pctChange(nest.latencyP99Ms, base.latencyP99Ms);
224 const thrPct = pctChange(
225 nest.throughputBytesPerSecAvg,
226 base.throughputBytesPerSecAvg,
227 );
228
229 // eslint-disable-next-line no-console
230 console.log(
231 `Requests/sec avg: ${fmtNum(base.requestsPerSecAvg)} -> ${fmtNum(nest.requestsPerSecAvg)} (${fmtPct(rpsPct)})`,
232 );
233 // eslint-disable-next-line no-console
234 console.log(
235 `Latency avg (ms): ${fmtNum(base.latencyAvgMs)} -> ${fmtNum(nest.latencyAvgMs)} (${fmtPct(latAvgPct)})`,
236 );
237 // eslint-disable-next-line no-console
238 console.log(
239 `Latency p99 (ms): ${fmtNum(base.latencyP99Ms)} -> ${fmtNum(nest.latencyP99Ms)} (${fmtPct(latP99Pct)})`,
240 );
241 // eslint-disable-next-line no-console
242 console.log(
243 `Throughput avg: ${fmtBytesPerSec(base.throughputBytesPerSecAvg)} -> ${fmtBytesPerSec(nest.throughputBytesPerSecAvg)} (${fmtPct(thrPct)})`,
244 );
245}
246
247async function runOne(
248 framework: Framework,

Callers 1

mainFunction · 0.85

Calls 5

pctChangeFunction · 0.85
fmtNumFunction · 0.85
fmtPctFunction · 0.85
fmtBytesPerSecFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected