@@ -66,27 +66,60 @@ jobs:
6666 github-token : ${{secrets.GITHUB_TOKEN}}
6767 script : |
6868 const benchmarkOutput = JSON.parse(`${{ steps.benchmark.outputs.BENCHMARK_OUTPUT }}`);
69-
7069 let significantChanges = false;
7170 let commentBody = "#### Performance Benchmark Results\n\n";
72-
71+
72+ function formatNumber(num) {
73+ return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
74+ }
75+
76+ function formatPercentage(pct) {
77+ const sign = pct >= 0 ? '+' : '';
78+ return `${sign}${pct.toFixed(2)}%`;
79+ }
80+
81+ function padRight(str, len) {
82+ return str.padEnd(len);
83+ }
84+
85+ function padLeft(str, len) {
86+ return str.padStart(len);
87+ }
88+
7389 for (const benchmark of benchmarkOutput) {
7490 if (benchmark.callgrind_summary && benchmark.callgrind_summary.summaries) {
75- for (const summary of benchmark.callgrind_summary.summaries) {
91+ const summary = benchmark.callgrind_summary.summaries[0];
92+ const irDiff = summary.events.Ir;
93+
94+ if (irDiff.diff_pct !== null) {
95+ const changePercentage = formatPercentage(irDiff.diff_pct);
96+ const color = irDiff.diff_pct > 0 ? "red" : "lime";
97+
98+ commentBody += "---\n\n";
99+ commentBody += `${benchmark.module_path} ${benchmark.id}:${benchmark.details}\n`;
100+ commentBody += `Instructions: \`${formatNumber(irDiff.old)}\` (master) -> \`${formatNumber(irDiff.new)}\` (HEAD) : `;
101+ commentBody += `$$\\color{${color}}${changePercentage.replace("%", "\\\\%")}$$\n\n`;
102+
103+ commentBody += "<details>\n<summary>Detailed metrics</summary>\n\n```\n";
104+ commentBody += `Baselines: master| HEAD\n`;
105+
76106 for (const [eventKind, costsDiff] of Object.entries(summary.events)) {
77- if (costsDiff.diff_pct !== null && Math.abs(costsDiff.diff_pct) > 5) {
78- significantChanges = true;
79- const changeDirection = costsDiff.diff_pct > 0 ? "Increase" : "Decrease";
80- const color = costsDiff.diff_pct > 0 ? "red" : "lime";
81- commentBody += `\`${benchmark.module_path}\` - ${eventKind}:\n`;
82- commentBody += `${changeDirection} of $$\\color{${color}}${Math.abs(costsDiff.diff_pct).toFixed(2)}\\\\%$$\n`;
83- commentBody += `Old: ${costsDiff.old}, New: ${costsDiff.new}\n\n`;
107+ if (costsDiff.diff_pct !== null) {
108+ const changePercentage = formatPercentage(costsDiff.diff_pct);
109+ const line = `${padRight(eventKind, 20)} ${padLeft(formatNumber(costsDiff.old), 11)}|${padLeft(formatNumber(costsDiff.new), 11)} ${padLeft(changePercentage, 15)}`;
110+ commentBody += `${line}\n`;
84111 }
85112 }
113+
114+ commentBody += "```\n</details>\n\n";
115+
116+ if (Math.abs(irDiff.diff_pct) > 5) {
117+ significantChanges = true;
118+ }
86119 }
87120 }
88121 }
89-
122+
90123 if (significantChanges) {
91124 github.rest.issues.createComment({
92125 issue_number: context.issue.number,
0 commit comments