@@ -112,19 +112,34 @@ jobs:
112
112
return;
113
113
}
114
114
115
+ const formatter = Intl.NumberFormat("en", {useGrouping: "always"});
116
+
117
+ const updated_str = formatter.format(updated);
118
+ const reference_str = formatter.format(reference);
119
+
115
120
const diff = updated - reference;
116
- const plus = diff > 0 ? "+" : "";
117
- const diff_str = `${plus}${diff}B`;
121
+ const diff_pct = (updated / reference) - 1;
122
+
123
+ const diff_str = Intl.NumberFormat("en", {
124
+ useGrouping: "always",
125
+ sign: "exceptZero"
126
+ }).format(diff);
127
+
128
+ const diff_pct_str = Intl.NumberFormat("en", {
129
+ style: "percent",
130
+ useGrouping: "always",
131
+ sign: "exceptZero",
132
+ maximumFractionDigits: 2
133
+ }).format(diff_pct);
118
134
119
135
if (diff !== 0) {
120
- const percent = (((updated / reference) - 1) * 100).toFixed(2);
121
136
// The body is created here and wrapped so "weirdly" to avoid whitespace at the start of the lines,
122
137
// which is interpreted as a code block by Markdown.
123
138
const body = `Below is the size of a hello-world Rust program linked with libstd with backtrace.
124
139
125
- Original binary size: **${reference} B**
126
- Updated binary size: **${updated} B**
127
- Difference: **${diff_str}** (${percent}% )`;
140
+ Original binary size: **${reference_str} B**
141
+ Updated binary size: **${updated_str} B**
142
+ Difference: **${diff_str} B ** (${diff_pct_str} )`;
128
143
129
144
github.rest.issues.createComment({
130
145
issue_number: context.issue.number,
0 commit comments