From 535df410480a49c430e36f81439a33d7b482d7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 8 Apr 2024 12:34:59 +0200 Subject: [PATCH] feat: add median to console output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 4 ++++ src/reporter/table.mjs | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e71dbfb..e7e972e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to - Align `iter/s` with `time (avg)` formatting. +### Changed + +- Add median (p50) to console output. + ## [0.2.2] - 2024-04-08 ### Changed diff --git a/src/reporter/table.mjs b/src/reporter/table.mjs index b6150ab..6597773 100644 --- a/src/reporter/table.mjs +++ b/src/reporter/table.mjs @@ -18,7 +18,7 @@ export function br({ }) { return ( '-'.repeat(size + 14 * avg + 14 * iter + 24 * min_max) + - (!percentiles ? '' : ` ${'-'.repeat(9 + 10 + 10)}`) + (!percentiles ? '' : ` ${'-'.repeat(9 + 10 + 10 + 10)}`) ); } @@ -54,10 +54,10 @@ export function header({ (!min_max ? '' : '(min … max)'.padStart(24, ' ')) + (!percentiles ? '' - : ` ${'p75'.padStart(9, ' ')} ${'p99'.padStart(9, ' ')} ${'p999'.padStart( + : ` ${'p50'.padStart(9, ' ')} ${'p75'.padStart(9, ' ')} ${'p99'.padStart( 9, ' ', - )}`) + )} ${'p999'.padStart(9, ' ')}`) ); } @@ -96,6 +96,8 @@ export function benchmark( (!percentiles ? '' : ` ${clr + .gray(colors, duration(stats.p50)) + .padStart(9 + 10 * colors, ' ')} ${clr .gray(colors, duration(stats.p75)) .padStart(9 + 10 * colors, ' ')} ${clr .gray(colors, duration(stats.p99))