@nestia/benchmark
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -39,3 +39,3 @@ "use strict"; | ||
}; | ||
var writeHead = function () { | ||
var head = function () { | ||
return [ | ||
@@ -53,3 +53,3 @@ "Type", | ||
}; | ||
var writeRow = function (title, s) { | ||
var row = function (title, s) { | ||
return [ | ||
@@ -65,2 +65,8 @@ title, | ||
}; | ||
var line = function (getter) { | ||
return "line [".concat(report.memories.map(function (m) { return Math.floor(getter(m.usage) / Math.pow(1024, 2)); }).join(", "), "]"); | ||
}; | ||
var legend = function (color, label) { | ||
return "<font color='".concat(color, "'>\u25A0</font> ").concat(label); | ||
}; | ||
return __spreadArray(__spreadArray(__spreadArray([ | ||
@@ -84,4 +90,4 @@ "# Benchmark Report", | ||
"", | ||
writeHead(), | ||
writeRow("Total", report.statistics), | ||
head(), | ||
row("Total", report.statistics), | ||
"", | ||
@@ -95,7 +101,15 @@ "> Unit: milliseconds", | ||
" y-axis \"Memory (MB)\"", | ||
" line [".concat(report.memories.map(function (m) { return Math.floor((m.usage.heapUsed + m.usage.external) / Math.pow(1024, 2)); }).join(", "), "]"), | ||
" ".concat(line(function (m) { return m.rss; })), | ||
" ".concat(line(function (m) { return m.heapTotal; })), | ||
" ".concat(line(function (m) { return m.heapUsed + m.external; })), | ||
" ".concat(line(function (m) { return m.heapUsed; })), | ||
"```", | ||
"", | ||
" - ".concat(legend("#5193d1", "Resident Set Size")), | ||
" - ".concat(legend("#64c779", "Heap Total")), | ||
" - ".concat(legend("#c85443", "Heap Used + External")), | ||
" - ".concat(legend("#eac644", "Heap Used Only")), | ||
"", | ||
"## Endpoints", | ||
writeHead() | ||
head() | ||
], __read(report.endpoints | ||
@@ -105,3 +119,3 @@ .slice() | ||
.map(function (endpoint) { | ||
return writeRow("".concat(endpoint.method, " ").concat(endpoint.path), endpoint); | ||
return row("".concat(endpoint.method, " ").concat(endpoint.path), endpoint); | ||
})), false), [ | ||
@@ -108,0 +122,0 @@ "", |
{ | ||
"name": "@nestia/benchmark", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "NestJS Performance Benchmark Program", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -9,3 +9,3 @@ import os from "os"; | ||
value === null ? "N/A" : (Math.floor(value * 100) / 100).toLocaleString(); | ||
const writeHead = () => | ||
const head = () => | ||
[ | ||
@@ -22,6 +22,3 @@ "Type", | ||
new Array(7).fill("----").join("|"); | ||
const writeRow = ( | ||
title: string, | ||
s: DynamicBenchmarker.IReport.IStatistics, | ||
) => | ||
const row = (title: string, s: DynamicBenchmarker.IReport.IStatistics) => | ||
[ | ||
@@ -36,2 +33,7 @@ title, | ||
].join(" | "); | ||
const line = (getter: (m: NodeJS.MemoryUsage) => number): string => | ||
`line [${report.memories.map((m) => Math.floor(getter(m.usage) / 1024 ** 2)).join(", ")}]`; | ||
const legend = (color: string, label: string): string => | ||
`<font color='${color}'>■</font> ${label}`; | ||
return [ | ||
@@ -55,4 +57,4 @@ `# Benchmark Report`, | ||
``, | ||
writeHead(), | ||
writeRow("Total", report.statistics), | ||
head(), | ||
row("Total", report.statistics), | ||
"", | ||
@@ -66,7 +68,15 @@ "> Unit: milliseconds", | ||
` y-axis "Memory (MB)"`, | ||
` line [${report.memories.map((m) => Math.floor((m.usage.heapUsed + m.usage.external) / 1024 ** 2)).join(", ")}]`, | ||
` ${line((m) => m.rss)}`, | ||
` ${line((m) => m.heapTotal)}`, | ||
` ${line((m) => m.heapUsed + m.external)}`, | ||
` ${line((m) => m.heapUsed)}`, | ||
"```", | ||
"", | ||
` - ${legend("#5193d1", "Resident Set Size")}`, | ||
` - ${legend("#64c779", "Heap Total")}`, | ||
` - ${legend("#c85443", "Heap Used + External")}`, | ||
` - ${legend("#eac644", "Heap Used Only")}`, | ||
"", | ||
"## Endpoints", | ||
writeHead(), | ||
head(), | ||
...report.endpoints | ||
@@ -76,3 +86,3 @@ .slice() | ||
.map((endpoint) => | ||
writeRow(`${endpoint.method} ${endpoint.path}`, endpoint), | ||
row(`${endpoint.method} ${endpoint.path}`, endpoint), | ||
), | ||
@@ -79,0 +89,0 @@ "", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79178
1445