@@ -33,19 +33,34 @@ runs:
33
33
return;
34
34
}
35
35
36
+ const formatter = Intl.NumberFormat("en", {useGrouping: "always"});
37
+
38
+ const updated_str = formatter.format(updated);
39
+ const reference_str = formatter.format(reference);
40
+
36
41
const diff = updated - reference;
37
- const plus = diff > 0 ? "+" : "";
38
- const diff_str = `${plus}${diff}B`;
42
+ const diff_pct = (updated / reference) - 1;
43
+
44
+ const diff_str = Intl.NumberFormat("en", {
45
+ useGrouping: "always",
46
+ sign: "exceptZero"
47
+ }).format(diff);
48
+
49
+ const diff_pct_str = Intl.NumberFormat("en", {
50
+ style: "percent",
51
+ useGrouping: "always",
52
+ sign: "exceptZero",
53
+ maximumFractionDigits: 2
54
+ }).format(diff_pct);
39
55
40
56
if (diff !== 0) {
41
- const percent = (((updated / reference) - 1) * 100).toFixed(2);
42
57
// The body is created here and wrapped so "weirdly" to avoid whitespace at the start of the lines,
43
58
// which is interpreted as a code block by Markdown.
44
59
const body = `Below is the size of a hello-world Rust program linked with libstd with backtrace.
45
60
46
- Original binary size: **${reference} B**
47
- Updated binary size: **${updated} B**
48
- Difference: **${diff_str}** (${percent}% )`;
61
+ Original binary size: **${reference_str} B**
62
+ Updated binary size: **${updated_str} B**
63
+ Difference: **${diff_str} B ** (${diff_pct_str} )`;
49
64
50
65
github.rest.issues.createComment({
51
66
issue_number: context.issue.number,
0 commit comments