Commit 76caac48 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

DevTools: Speedup perf monitor draw

Do not use Number.p.toLocaleString as it recreates the formatter on every
invocation.

Change-Id: I5b98ed61e448ca867a1d5317ffc50e0066760b50
Reviewed-on: https://chromium-review.googlesource.com/c/1295311Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601807}
parent 907a13fb
...@@ -517,13 +517,19 @@ PerformanceMonitor.PerformanceMonitor.MetricIndicator = class { ...@@ -517,13 +517,19 @@ PerformanceMonitor.PerformanceMonitor.MetricIndicator = class {
* @return {string} * @return {string}
*/ */
static _formatNumber(value, info) { static _formatNumber(value, info) {
if (!PerformanceMonitor.PerformanceMonitor.MetricIndicator._numberFormatter) {
PerformanceMonitor.PerformanceMonitor.MetricIndicator._numberFormatter =
new Intl.NumberFormat('en-US', {maximumFractionDigits: 1});
PerformanceMonitor.PerformanceMonitor.MetricIndicator._percentFormatter =
new Intl.NumberFormat('en-US', {maximumFractionDigits: 1, style: 'percent'});
}
switch (info.format) { switch (info.format) {
case PerformanceMonitor.PerformanceMonitor.Format.Percent: case PerformanceMonitor.PerformanceMonitor.Format.Percent:
return value.toLocaleString('en-US', {maximumFractionDigits: 1, style: 'percent'}); return PerformanceMonitor.PerformanceMonitor.MetricIndicator._percentFormatter.format(value);
case PerformanceMonitor.PerformanceMonitor.Format.Bytes: case PerformanceMonitor.PerformanceMonitor.Format.Bytes:
return Number.bytesToString(value); return Number.bytesToString(value);
default: default:
return value.toLocaleString('en-US', {maximumFractionDigits: 1}); return PerformanceMonitor.PerformanceMonitor.MetricIndicator._numberFormatter.format(value);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment