diff --git a/src/lib.js b/src/lib.js index 51655d2..d26c048 100644 --- a/src/lib.js +++ b/src/lib.js @@ -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), + }), }, }, } @@ -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}`) diff --git a/tests/formatting.js b/tests/formatting.js index 795a9bf..9ad20f4 100644 --- a/tests/formatting.js +++ b/tests/formatting.js @@ -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) diff --git a/tests/test.js b/tests/test.js index c0955ce..746cff6 100644 --- a/tests/test.js +++ b/tests/test.js @@ -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) @@ -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) diff --git a/tests/test.ts b/tests/test.ts index c0955ce..746cff6 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -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) @@ -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)