function table(stats, numWarmups, numTrials, numRepeats) {
const longestTime = d3.max(stats.map(s => s.max));
const best = d3.min(stats, d => d.median);
return md`
### ${
stats.running
? stats.warmup
? `Running Warmup ${stats.currentTrial} of ${numWarmups}`
: `Running Trial ${stats.currentTrial} of ${numTrials}`
: `${numTrials} Trials`
} ${
numRepeats > 1
? `<small>(with ${numRepeats} repeats per trial)</small>`
: ''
}
<div style="max-width: 700px"><div style="background: #eee;"><div style="transition: all; background:black;width:${(stats.currentTrial /
numTrials) *
100}%;height:3px;"></div>
</div>
<table style="max-width: 100%">
<thead>
<tr>
<th>Method</th>
<th style="text-align:right">Mean</th>
<th style="text-align:right">%Median</th>
${numRepeats > 1 ? '' : `<th style="text-align:right">Stdev</th>`}
<th style="text-align:right">Range</th>
<th style="text-align:right">Histogram</th>
</tr>
</thead>
<tbody>
${stats.map(
e =>
html`<tr>
<td>${e.name}</td>
<td style="text-align:right; font-variant-numeric: tabular-nums">${fmt(
e.mean
)} ${numRepeats > 1 ? '' : `± ${fmt(e.sem)}`} ms</td>
<td style="text-align:right; font-variant-numeric: tabular-nums">${
e.median === best ? "—" : `+${commas(100 * (e.median / best - 1))}%`
}</td>
${
numRepeats > 1
? ''
: `<td style="text-align:right; font-variant-numeric: tabular-nums">${fmt(
e.sd
)}</td>`
}
<td style="text-align:right; font-variant-numeric: tabular-nums">${fmt(
e.min
)} - ${fmt(e.max)} ms</td>
<td style="text-align:right; font-variant-numeric: tabular-nums">${html`${hist(
e.times,
{
domain: [0, longestTime],
width: 120,
height: 20,
thresholds: 25
}
)}`}</td>
</tr>`
)}
</tbody>
</table>
${
numRepeats > 1
? md`<small>**Note:** Because the number of repeats per trial is larger than 1, some statistics cannot be computed.</small>`
: ''
}`;
}