summaryrefslogtreecommitdiffstats
path: root/js/src/devtools/gc-ubench/harness.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /js/src/devtools/gc-ubench/harness.js
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/devtools/gc-ubench/harness.js')
-rw-r--r--js/src/devtools/gc-ubench/harness.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/js/src/devtools/gc-ubench/harness.js b/js/src/devtools/gc-ubench/harness.js
index db7fa06d63..124baa17a5 100644
--- a/js/src/devtools/gc-ubench/harness.js
+++ b/js/src/devtools/gc-ubench/harness.js
@@ -254,14 +254,19 @@ var AllocationLoadManager = class {
var gLoadMgr = undefined;
function format_with_units(n, label, shortlabel, kbase) {
+ function format(n, prefix, unit) {
+ let s = Number.isInteger(n) ? n.toString() : n.toFixed(2);
+ return `${s}${prefix}${unit}`;
+ }
+
if (n < kbase * 4) {
return `${n} ${label}`;
} else if (n < kbase ** 2 * 4) {
- return `${(n / kbase).toFixed(2)}K${shortlabel}`;
+ return format(n / kbase, 'K', shortlabel);
} else if (n < kbase ** 3 * 4) {
- return `${(n / kbase ** 2).toFixed(2)}M${shortlabel}`;
+ return format(n / kbase ** 2, 'M', shortlabel);
}
- return `${(n / kbase ** 3).toFixed(2)}G${shortlabel}`;
+ return format(n / kbase ** 3, 'G', shortlabel);
}
function format_bytes(bytes) {