From 2face3c2922c8ca853885c55c1648a15cc3bcb10 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:36:08 +0100 Subject: [PATCH] Format benchmark numbers as inline code with thousands separators Wrap every numeric cell in inline code and group thousands (e.g. `3,891.22 ms`, `+1,680.87`) so the comment is easier to scan; n/a stays plain. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/benchmark-comment.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmark-comment.js b/.github/workflows/benchmark-comment.js index 0de20aac13..75f0658439 100644 --- a/.github/workflows/benchmark-comment.js +++ b/.github/workflows/benchmark-comment.js @@ -110,11 +110,11 @@ function changeCell(before, after, lowerIsBetter) { const percent = Number((((after - before) / before) * 100).toFixed(1)); if (percent === 0) { - return ':white_circle: 0%'; + return `:white_circle: ${code('0%')}`; } const improved = lowerIsBetter ? percent < 0 : percent > 0; - return `${improved ? ':green_circle:' : ':red_circle:'} ${percent > 0 ? '+' : ''}${trimNumber(percent)}%`; + return `${improved ? ':green_circle:' : ':red_circle:'} ${code(`${percent > 0 ? '+' : ''}${trimNumber(percent)}%`)}`; } function detailTable(rows) { @@ -326,16 +326,16 @@ function markdownText(value) { } function formatMs(value) { - return formatNumber(value, 2); + return code(formatNumber(value, 2)); } function formatMsUnit(value) { const formatted = formatNumber(value, 2); - return formatted === 'n/a' ? formatted : `${formatted} ms`; + return formatted === 'n/a' ? formatted : code(`${formatted} ms`); } function formatRate(value) { - return formatNumber(value, 2); + return code(formatNumber(value, 2)); } function formatCount(value) { @@ -343,7 +343,7 @@ function formatCount(value) { return 'n/a'; } - return `${Math.round(value)}`; + return code(Math.round(value).toLocaleString('en-US')); } function formatDelta(before, after) { @@ -352,7 +352,8 @@ function formatDelta(before, after) { } const difference = Number((after - before).toFixed(2)); - return `${difference > 0 ? '+' : ''}${trimNumber(difference)}`; + const sign = difference > 0 ? '+' : difference < 0 ? '-' : ''; + return code(`${sign}${formatNumber(Math.abs(difference), 2)}`); } function formatNumber(value, decimals) { @@ -360,7 +361,14 @@ function formatNumber(value, decimals) { return 'n/a'; } - return trimNumber(Number(value).toFixed(decimals)); + return trimNumber(Number(value).toLocaleString('en-US', { + minimumFractionDigits: decimals, + maximumFractionDigits: decimals, + })); +} + +function code(text) { + return text === 'n/a' ? text : `\`${text}\``; } function trimNumber(value) {