diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index 8c014ef26..2bd439aea 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -1,6 +1,6 @@ { "name": "@nestia/benchmark", - "version": "0.2.0", + "version": "0.2.3", "description": "NestJS Performance Benchmark Program", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/benchmark/src/internal/DynamicBenchmarkReporter.ts b/packages/benchmark/src/internal/DynamicBenchmarkReporter.ts index 94c1d9c9a..b5ebde65a 100644 --- a/packages/benchmark/src/internal/DynamicBenchmarkReporter.ts +++ b/packages/benchmark/src/internal/DynamicBenchmarkReporter.ts @@ -6,7 +6,7 @@ export namespace DynamicBenchmarWriter { export const markdown = (report: DynamicBenchmarker.IReport): string => { const format = (value: number | null) => value === null ? "N/A" : (Math.floor(value * 100) / 100).toLocaleString(); - const writeHead = () => + const head = () => [ "Type", "Count", @@ -18,10 +18,7 @@ export namespace DynamicBenchmarWriter { ].join(" | ") + "\n" + new Array(7).fill("----").join("|"); - const writeRow = ( - title: string, - s: DynamicBenchmarker.IReport.IStatistics, - ) => + const row = (title: string, s: DynamicBenchmarker.IReport.IStatistics) => [ title, s.count.toLocaleString(), @@ -31,6 +28,12 @@ export namespace DynamicBenchmarWriter { format(s.minimum), format(s.maximum), ].join(" | "); + const line = ( + title: string, + getter: (m: NodeJS.MemoryUsage) => number, + ): string => + `line "${title}" [${report.memories.map((m) => Math.floor(getter(m.usage) / 1024 ** 2)).join(", ")}]`; + return [ `# Benchmark Report`, "> Generated by [`@nestia/benchmark`](https://github.com/samchon/nestia)", @@ -49,26 +52,34 @@ export namespace DynamicBenchmarWriter { ` - Complete: ${report.completed_at}`, ` - Elapsed: ${(new Date(report.completed_at).getTime() - new Date(report.started_at).getTime()).toLocaleString()} ms`, ``, - writeHead(), - writeRow("Total", report.statistics), + head(), + row("Total", report.statistics), "", "> Unit: milliseconds", "", - "## Memory Usage", + "## Memory Consumptions", "```mermaid", "xychart-beta", ` x-axis "Time (second)"`, ` y-axis "Memory (MB)"`, - ` line [${report.memories.map((m) => Math.floor((m.usage.heapUsed + m.usage.external) / 1024 ** 2)).join(", ")}]`, + ` ${line("Resident Set Size", (m) => m.rss)}`, + ` ${line("Heap Total", (m) => m.heapTotal)}`, + ` ${line("Heap Used + External", (m) => m.heapUsed + m.external)}`, + ` ${line("Heap Used Only", (m) => m.heapUsed)}`, "```", "", + `> - 🟦 Resident Set Size`, + `> - 🟢 Heap Total`, + `> - 🔴 Heap Used + External`, + `> - 🟡 Heap Used Only`, + "", "## Endpoints", - writeHead(), + head(), ...report.endpoints .slice() .sort((a, b) => (b.mean ?? 0) - (a.mean ?? 0)) .map((endpoint) => - writeRow(`${endpoint.method} ${endpoint.path}`, endpoint), + row(`${endpoint.method} ${endpoint.path}`, endpoint), ), "", "> Unit: milliseconds", diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 26f7d7ebb..4fac6bc47 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -1,6 +1,6 @@ { "name": "@nestia/migrate", - "version": "0.15.1", + "version": "0.15.2", "description": "Migration program from swagger to NestJS", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -36,7 +36,7 @@ }, "homepage": "https://nestia.io", "devDependencies": { - "@nestia/benchmark": "^0.2.0", + "@nestia/benchmark": "^0.2.2", "@nestia/core": "^3.8.1", "@nestia/e2e": "^0.7.0", "@nestia/fetcher": "^3.8.1", diff --git a/website/package.json b/website/package.json index f1cb68d4f..57229d968 100644 --- a/website/package.json +++ b/website/package.json @@ -23,7 +23,7 @@ "@mui/icons-material": "5.15.6", "@mui/material": "5.15.6", "@mui/system": "5.15.6", - "@nestia/migrate": "^0.15.0", + "@nestia/migrate": "^0.15.2", "@samchon/openapi": "^0.4.2", "@stackblitz/sdk": "^1.9.0", "js-yaml": "^4.1.0",