INNER CODE UNIT · TypeScript

formatResults

jeffijoe/awilix · benchmarks/helpers.ts:57

export function formatResults(bench: Bench): {
  rows: Array<{ Name: string; 'ops/sec': number; 'avg (ns)': number; 'p99 (ns)': number }>
  markdown: string
} {
  const rows = bench.tasks.map((t) => {
    const r = t.result as any
    return {
      Name: t.name,
      'ops/sec': Math.round(r.throughput.mean),
      'avg (ns)': Math.round(r.latency.mean * 1e6),
      'p99 (ns)': Math.round(r.latency.p99 * 1e6),
    }
  })

  let md = '| Name | ops/sec | avg (ns) | p99 (ns) |\n'
  md += '|------|---------|----------|----------|\n'
  for (const row of rows) {
    md += `| ${row.Name} | ${row['ops/sec'].toLocaleString()} | ${row['avg (ns)'].toLocaleString()} | ${row['p99 (ns)'].toLocaleString()} |\n`

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…