Skip to content

Commit

Permalink
Print the median absolute deviations as percentages (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
pallosp authored Jan 30, 2025
1 parent 9bdebc1 commit 9e95321
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,23 @@ export class Bench extends EventTarget {
): (null | Record<string, number | string | undefined>)[] {
return this.tasks.map(task => {
if (task.result) {
const { error, latency, throughput } = task.result
/* eslint-disable perfectionist/sort-objects */
return task.result.error
return error
? {
'Task name': task.name,
Error: task.result.error.message,
Stack: task.result.error.stack,
Error: error.message,
Stack: error.stack,
}
: (convert?.(task) ?? {
'Task name': task.name,
'Latency avg (ns)': `${formatNumber(mToNs(task.result.latency.mean), 5, 2)} \xb1 ${task.result.latency.rme.toFixed(2)}%`,
'Latency avg (ns)': `${formatNumber(mToNs(latency.mean), 5, 2)} \xb1 ${latency.rme.toFixed(2)}%`,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
'Latency med (ns)': `${formatNumber(mToNs(task.result.latency.p50!), 5, 2)} \xb1 ${formatNumber(mToNs(task.result.latency.mad!), 5, 2)}`,
'Throughput avg (ops/s)': `${Math.round(task.result.throughput.mean).toString()} \xb1 ${task.result.throughput.rme.toFixed(2)}%`,
'Latency med (ns)': `${formatNumber(mToNs(latency.p50!), 5, 2)} \xb1 ${formatNumber(mToNs(latency.mad!), 5, 2)}`,
'Throughput avg (ops/s)': `${Math.round(throughput.mean).toString()} \xb1 ${throughput.rme.toFixed(2)}%`,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
'Throughput med (ops/s)': `${Math.round(task.result.throughput.p50!).toString()} \xb1 ${Math.round(task.result.throughput.mad!).toString()}`,
Samples: task.result.latency.samples.length,
'Throughput med (ops/s)': `${Math.round(throughput.p50!).toString()} \xb1 ${Math.round(throughput.mad!).toString()}`,
Samples: latency.samples.length,
})
/* eslint-enable perfectionist/sort-objects */
}
Expand Down

0 comments on commit 9e95321

Please sign in to comment.