From bf1e04c64fb90c31a9e1646bb9376ba2f1a64c61 Mon Sep 17 00:00:00 2001 From: Kaiyue Pan Date: Fri, 10 Jan 2020 14:31:08 -0500 Subject: [PATCH] [quality][performance] Format performance numbers in the log - formatted the performance numbers in the log to one decimal place. Signed-off-by: Kaiyue Pan --- packages/core/src/browser/frontend-application.ts | 4 ++-- packages/plugin-ext/src/hosted/browser/hosted-plugin.ts | 2 +- packages/plugin-ext/src/main/browser/webview/pre/main.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/browser/frontend-application.ts b/packages/core/src/browser/frontend-application.ts index d8db377935205..54e2c3af96cc4 100644 --- a/packages/core/src/browser/frontend-application.ts +++ b/packages/core/src/browser/frontend-application.ts @@ -367,9 +367,9 @@ export class FrontendApplication { performance.measure(name, startMark, endMark); for (const item of performance.getEntriesByName(name)) { if (item.duration > 100) { - console.warn(item.name + ' is slow, took: ' + item.duration + ' ms'); + console.warn(item.name + ' is slow, took: ' + item.duration.toFixed(1) + ' ms'); } else { - console.debug(item.name + ' took ' + item.duration + ' ms'); + console.debug(item.name + ' took ' + item.duration.toFixed(1) + ' ms'); } } performance.clearMeasures(name); diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index 1b7c05fdea7cf..10c3f2c342fe6 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -597,7 +597,7 @@ export class HostedPluginSupport { protected logMeasurement(prefix: string, count: number, measurement: () => number): void { const pluginCount = `${count} plugin${count === 1 ? '' : 's'}`; - console.log(`[${this.clientId}] ${prefix} of ${pluginCount} took: ${measurement()} ms`); + console.log(`[${this.clientId}] ${prefix} of ${pluginCount} took: ${measurement().toFixed(1)} ms`); } protected readonly webviewsToRestore = new Set(); diff --git a/packages/plugin-ext/src/main/browser/webview/pre/main.js b/packages/plugin-ext/src/main/browser/webview/pre/main.js index b667df984dd0d..383d400a30a14 100644 --- a/packages/plugin-ext/src/main/browser/webview/pre/main.js +++ b/packages/plugin-ext/src/main/browser/webview/pre/main.js @@ -506,7 +506,7 @@ loadTimeout = setTimeout(() => { clearTimeout(loadTimeout); loadTimeout = undefined; - console.warn('Loading webview is slow, took: ' + timeoutDelay + 'ms'); + console.warn('Loading webview is slow, took: ' + timeoutDelay.toFixed(1) + 'ms'); onLoad(newFrame.contentDocument, newFrame.contentWindow); }, timeoutDelay);