Index: third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/util.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/util.js b/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/util.js |
index d032e2a1784a01a935025ac20417cc4e21883d33..7f541dbfa0154d942fe5fe21f41c5c232d1dad7b 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/util.js |
+++ b/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/util.js |
@@ -18,6 +18,7 @@ |
/* globals self URL */ |
const ELLIPSIS = '\u2026'; |
+const NBSP = '\xa0'; |
const RATINGS = { |
PASS: {label: 'pass', minScore: 75}, |
@@ -59,6 +60,16 @@ class Util { |
return (size / 1024).toLocaleString(undefined, {maximumFractionDigits: decimalPlaces}); |
} |
+ /** |
+ * @param {number} ms |
+ * @param {number=} granularity Controls how coarse the displayed value is, defaults to 10 |
+ * @return {string} |
+ */ |
+ static formatMilliseconds(ms, granularity = 10) { |
+ const coarseTime = Math.round(ms / granularity) * granularity; |
+ return `${coarseTime.toLocaleString()}${NBSP}ms`; |
+ } |
+ |
/** |
* Format time. |
* @param {string} date |