diff --git a/src/vs/base/common/performance.d.ts b/src/vs/base/common/performance.d.ts index 804f290b7f2a82def3054f3a6ff5e144be6bcdc4..4258c8d76af44280aebde092bacb421d24ef3c4b 100644 --- a/src/vs/base/common/performance.d.ts +++ b/src/vs/base/common/performance.d.ts @@ -11,7 +11,8 @@ export interface PerformanceEntry { } export function mark(name: string): void; -export function measure(name: string, from?: string, to?: string): void; + +export function measure(name: string, from?: string, to?: string): PerformanceEntry; /** * Time something, shorthant for `mark` and `measure` @@ -23,6 +24,7 @@ export function time(name: string): { stop(): void }; */ export function getEntries(type: 'mark' | 'measure'): PerformanceEntry[]; +export function getEntry(type: 'mark' | 'measure', name: string): PerformanceEntry; type ExportData = any[]; export function importEntries(data: ExportData): void; diff --git a/src/vs/base/common/performance.js b/src/vs/base/common/performance.js index c4cd3c7a54471460bb11f96114649820fcd6079e..8cfcb4794bd9b0655e6fd7d478b57ec779f78601 100644 --- a/src/vs/base/common/performance.js +++ b/src/vs/base/common/performance.js @@ -34,11 +34,11 @@ define([], function () { return global._performanceEntries.splice(0); } - function getEntries(type) { + function getEntries(type, name) { const result = []; const entries = global._performanceEntries; for (let i = 0; i < entries.length; i += 4) { - if (entries[i] === type) { + if (entries[i] === type && (name === void 0 || entries[i + 1] === name)) { result.push({ type: entries[i], name: entries[i + 1], @@ -53,6 +53,20 @@ define([], function () { }); } + function getEntry(type, name) { + const entries = global._performanceEntries; + for (let i = 0; i < entries.length; i += 4) { + if (entries[i] === type && entries[i + 1] === name) { + return { + type: entries[i], + name: entries[i + 1], + startTime: entries[i + 2], + duration: entries[i + 3], + }; + } + } + } + function mark(name) { global._performanceEntries.push('mark', name, _now(), 0); if (typeof console.timeStamp === 'function') { @@ -103,6 +117,7 @@ define([], function () { measure: measure, time: time, getEntries: getEntries, + getEntry: getEntry, importEntries: importEntries, exportEntries: exportEntries }; diff --git a/src/vs/workbench/electron-browser/bootstrap/index.js b/src/vs/workbench/electron-browser/bootstrap/index.js index 4fcb345a224b110d0dc13600461015d048020b83..4ba96f7418faaaeef358d7c4ee2a2a657d8b077b 100644 --- a/src/vs/workbench/electron-browser/bootstrap/index.js +++ b/src/vs/workbench/electron-browser/bootstrap/index.js @@ -171,13 +171,12 @@ function main() { } // Perf Counters - const timers = window.MonacoEnvironment.timers = { + window.MonacoEnvironment.timers = { isInitialStartup: !!configuration.isInitialStartup, hasAccessibilitySupport: !!configuration.accessibilitySupport, start: configuration.perfStartTime, appReady: configuration.perfAppReady, - windowLoad: configuration.perfWindowLoadTime, - beforeLoadWorkbenchMain: Date.now() + windowLoad: configuration.perfWindowLoadTime }; const workbenchMainClock = perf.time('loadWorkbenchMain'); @@ -187,7 +186,6 @@ function main() { 'vs/css!vs/workbench/workbench.main' ], function () { workbenchMainClock.stop(); - timers.afterLoadWorkbenchMain = Date.now(); process.lazyEnv.then(function () { perf.mark('main/startup'); diff --git a/src/vs/workbench/services/timer/common/timerService.ts b/src/vs/workbench/services/timer/common/timerService.ts index fb523a04dc41c22ea999f5dd2f16a4bb151fb33f..e3d4887ddbd9d1b7b099c46c7ad406840ed41d24 100644 --- a/src/vs/workbench/services/timer/common/timerService.ts +++ b/src/vs/workbench/services/timer/common/timerService.ts @@ -88,9 +88,6 @@ export interface IInitData { windowLoad: number; - beforeLoadWorkbenchMain: number; - afterLoadWorkbenchMain: number; - isInitialStartup: boolean; hasAccessibilitySupport: boolean; } diff --git a/src/vs/workbench/services/timer/node/timerService.ts b/src/vs/workbench/services/timer/node/timerService.ts index 2aafef2572931dc9796d6b8b0d16365f8678b588..4e3817cd0b60e0a04cb9a8f110af4e06da129075 100644 --- a/src/vs/workbench/services/timer/node/timerService.ts +++ b/src/vs/workbench/services/timer/node/timerService.ts @@ -6,7 +6,7 @@ import { ITimerService, IStartupMetrics, IInitData, IMemoryInfo } from 'vs/workbench/services/timer/common/timerService'; import { virtualMachineHint } from 'vs/base/node/id'; - +import * as perf from 'vs/base/common/performance'; import * as os from 'os'; export class TimerService implements ITimerService { @@ -17,9 +17,6 @@ export class TimerService implements ITimerService { public readonly appReady: number; public readonly windowLoad: number; - public readonly beforeLoadWorkbenchMain: number; - public readonly afterLoadWorkbenchMain: number; - public readonly isInitialStartup: boolean; public readonly hasAccessibilitySupport: boolean; @@ -43,9 +40,6 @@ export class TimerService implements ITimerService { this.appReady = initData.appReady; this.windowLoad = initData.windowLoad; - this.beforeLoadWorkbenchMain = initData.beforeLoadWorkbenchMain; - this.afterLoadWorkbenchMain = initData.afterLoadWorkbenchMain; - this.isInitialStartup = initData.isInitialStartup; this.hasAccessibilitySupport = initData.hasAccessibilitySupport; } @@ -97,11 +91,11 @@ export class TimerService implements ITimerService { timers: { ellapsedExtensions: this.afterExtensionLoad - this.beforeExtensionLoad, ellapsedExtensionsReady: this.afterExtensionLoad - start, - ellapsedRequire: this.afterLoadWorkbenchMain - this.beforeLoadWorkbenchMain, + ellapsedRequire: perf.getEntry('measure', 'loadWorkbenchMain').duration, ellapsedViewletRestore: this.restoreViewletDuration, ellapsedEditorRestore: this.restoreEditorsDuration, ellapsedWorkbench: this.workbenchStarted - this.beforeWorkbenchOpen, - ellapsedWindowLoadToRequire: this.beforeLoadWorkbenchMain - this.windowLoad, + ellapsedWindowLoadToRequire: perf.getEntry('mark', 'loadWorkbenchMain/start').startTime - this.windowLoad, ellapsedTimersToTimersComputed: Date.now() - now }, platform,