Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve string output for Req/Sec #498

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/printResult.js
Original file line number Diff line number Diff line change
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
Loading