Skip to content

Commit

Permalink
fix: add upper/lower values to BMF throughput report
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 Sep 30, 2024
1 parent f188e81 commit 4555059
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ export const convertReportToBmf = report => {
},
throughput: {
value: stats?.iters,
...(typeof stats?.max === 'number' &&
stats.max > 0 && {
lower_value: 1e9 / checkDividend(stats.max),
}),
...(typeof stats?.min === 'number' &&
stats.min > 0 && {
upper_value: 1e9 / checkDividend(stats.min),
}),
},
},
}
Expand Down Expand Up @@ -200,6 +208,7 @@ export const mergeDeepRight = (target, source) => {
}

export const checkDividend = n => {
if (n == null) throw new TypeError(`Invalid dividend: ${n}`)
if ('number' !== typeof n)
throw new TypeError(`expected number, got ${n.constructor.name}`)
if (n === 0 || Number.isNaN(n)) throw new RangeError(`Invalid dividend: ${n}`)
Expand Down
2 changes: 1 addition & 1 deletion tests/formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ group({ summary: true }, () => {

await run({
units: true, // print units cheatsheet (default: false)
avg: true, // enable/disable avg column (default: true)
avg: true, // enable/disable time/iter average column (default: true)
json: false, // enable/disable json output or set json output format (default: false)
colors: true, // enable/disable colors (default: true)
min_max: true, // enable/disable (min...max) column (default: true)
Expand Down
4 changes: 2 additions & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ group({ name: 'group2', summary: false }, () => {
})

const report = await run({
avg: true, // enable/disable avg column (default: true)
avg: true, // enable/disable time/iter average column (default: true)
json: false, // enable/disable json output or set json output format (default: false)
colors: true, // enable/disable colors (default: true)
min_max: true, // enable/disable (min...max) column (default: true)
Expand All @@ -54,7 +54,7 @@ const report = await run({
console.log(report)

await run({
avg: true, // enable/disable avg column (default: true)
avg: true, // enable/disable time/iter average column (default: true)
json: false, // enable/disable json output or set json output format (default: false)
colors: true, // enable/disable colors (default: true)
min_max: true, // enable/disable (min...max) column (default: true)
Expand Down
4 changes: 2 additions & 2 deletions tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ group({ name: 'group2', summary: false }, () => {
})

const report = await run({
avg: true, // enable/disable avg column (default: true)
avg: true, // enable/disable time/iter average column (default: true)
json: false, // enable/disable json output or set json output format (default: false)
colors: true, // enable/disable colors (default: true)
min_max: true, // enable/disable (min...max) column (default: true)
Expand All @@ -54,7 +54,7 @@ const report = await run({
console.log(report)

await run({
avg: true, // enable/disable avg column (default: true)
avg: true, // enable/disable time/iter average column (default: true)
json: false, // enable/disable json output or set json output format (default: false)
colors: true, // enable/disable colors (default: true)
min_max: true, // enable/disable (min...max) column (default: true)
Expand Down

0 comments on commit 4555059

Please sign in to comment.