Skip to content

Commit

Permalink
feat: add median to console output
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
jerome-benoit committed Apr 8, 2024
1 parent 217da26 commit 535df41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/reporter/table.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`)
);
}

Expand Down Expand Up @@ -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, ' ')}`)
);
}

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 535df41

Please sign in to comment.