Skip to content

Commit

Permalink
improve string output for Req/Sec (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Oct 3, 2023
1 parent ec3c755 commit 5538496
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/printResult.js
Expand Up @@ -30,7 +30,7 @@ const printResult = (result, opts) => {
head: asColor(chalk.cyan, ['Stat', '1%', '2.5%', '50%', '97.5%', 'Avg', 'Stdev', 'Min'])
})

requests.push(asHighRow(chalk.bold('Req/Sec'), result.requests))
requests.push(asHighRow(chalk.bold('Req/Sec'), asNumber(result.requests)))
requests.push(asHighRow(chalk.bold('Bytes/Sec'), asBytes(result.throughput)))
logToLocalStr(requests.toString())

Expand Down Expand Up @@ -135,6 +135,18 @@ function asMs (stat) {
return result
}

function asNumber (stat) {
const result = Object.create(null)
for (const k of Object.keys(stat)) {
result[k] = stat[k].toLocaleString(undefined, {
// to show all digits
maximumFractionDigits: 20
})
}

return result
}

function asBytes (stat) {
const result = Object.create(stat)

Expand Down

0 comments on commit 5538496

Please sign in to comment.