perf - more fine grained window counters

This commit is contained in:
Benjamin Pasero 2021-04-09 10:00:51 +02:00
parent 65a8d0905e
commit 9f9f73d704
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65
4 changed files with 42 additions and 6 deletions

View file

@ -247,8 +247,11 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
}
// Create the browser window.
// Create the browser window
mark('code/willCreateCodeBrowserWindow');
this._win = new BrowserWindow(options);
mark('code/didCreateCodeBrowserWindow');
this._id = this._win.id;
// Open devtools if instructed from command line args
@ -280,6 +283,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
if (isFullscreenOrMaximized) {
mark('code/willMaximizeCodeWindow');
this._win.maximize();
if (this.windowState.mode === WindowMode.Fullscreen) {
@ -289,6 +293,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
if (!this._win.isVisible()) {
this._win.show(); // to reduce flicker from the default window size to maximize, we only show after maximize
}
mark('code/didMaximizeCodeWindow');
}
this._lastFocusTime = Date.now(); // since we show directly, we need to set the last focus time too
@ -915,6 +920,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
private restoreWindowState(state?: IWindowState): [IWindowState, boolean? /* has multiple displays */] {
mark('code/willRestoreCodeWindowState');
let hasMultipleDisplays = false;
if (state) {
try {
@ -927,6 +934,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
}
mark('code/didRestoreCodeWindowState');
return [state || defaultWindowState(), hasMultipleDisplays];
}

View file

@ -1211,13 +1211,13 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
const state = this.windowsStateHandler.getNewWindowState(configuration);
// Create the window
mark('code/willCreateWindow');
mark('code/willCreateCodeWindow');
const createdWindow = window = this.instantiationService.createInstance(CodeWindow, {
state,
extensionDevelopmentPath: configuration.extensionDevelopmentPath,
isExtensionTestHost: !!configuration.extensionTestsPath
});
mark('code/didCreateWindow');
mark('code/didCreateCodeWindow');
// Add as window tab if configured (macOS only)
if (options.forceNewTabbedWindow) {

View file

@ -171,7 +171,7 @@ class PerfModelContentProvider implements ITextModelContentProvider {
table.push(['require(main.bundle.js)', metrics.timers.ellapsedLoadMainBundle, '[main]', `initial startup: ${metrics.initialStartup}`]);
table.push(['start crash reporter', metrics.timers.ellapsedCrashReporter, '[main]', `initial startup: ${metrics.initialStartup}`]);
table.push(['serve main IPC handle', metrics.timers.ellapsedMainServer, '[main]', `initial startup: ${metrics.initialStartup}`]);
table.push(['create window', metrics.timers.ellapsedWindowCreate, '[main]', `initial startup: ${metrics.initialStartup}`]);
table.push(['create window', metrics.timers.ellapsedWindowCreate, '[main]', `initial startup: ${metrics.initialStartup}, ${metrics.initialStartup ? `state: ${metrics.timers.ellapsedWindowRestoreState}ms, widget: ${metrics.timers.ellapsedBrowserWindowCreate}ms, show: ${metrics.timers.ellapsedWindowMaximize}ms` : ''}`]);
table.push(['app.isReady => window.loadUrl()', metrics.timers.ellapsedWindowLoad, '[main]', `initial startup: ${metrics.initialStartup}`]);
table.push(['window.loadUrl() => begin to require(workbench.desktop.main.js)', metrics.timers.ellapsedWindowLoadToRequire, '[main->renderer]', StartupKindToString(metrics.windowKind)]);
table.push(['require(workbench.desktop.main.js)', metrics.timers.ellapsedRequire, '[renderer]', `cached data: ${(metrics.didUseCachedData ? 'YES' : 'NO')}${stats ? `, node_modules took ${stats.nodeRequireTotal}ms` : ''}`]);

View file

@ -201,10 +201,34 @@ export interface IStartupMetrics {
* The time it took to create the window.
*
* * Happens in the main-process
* * Measured with the `willCreateWindow` and `didCreateWindow` performance marks.
* * Measured with the `willCreateCodeWindow` and `didCreateCodeWindow` performance marks.
*/
readonly ellapsedWindowCreate?: number;
/**
* The time it took to create the electron browser window.
*
* * Happens in the main-process
* * Measured with the `willCreateCodeBrowserWindow` and `didCreateCodeBrowserWindow` performance marks.
*/
readonly ellapsedBrowserWindowCreate?: number;
/**
* The time it took to restore and validate window state.
*
* * Happens in the main-process
* * Measured with the `willRestoreCodeWindowState` and `didRestoreCodeWindowState` performance marks.
*/
readonly ellapsedWindowRestoreState?: number;
/**
* The time it took to maximize/show the window.
*
* * Happens in the main-process
* * Measured with the `willMaximizeCodeWindow` and `didMaximizeCodeWindow` performance marks.
*/
readonly ellapsedWindowMaximize?: number;
/**
* The time it took to tell electron to open/restore a renderer (browser window).
*
@ -558,7 +582,10 @@ export abstract class AbstractTimerService implements ITimerService {
ellapsedLoadMainBundle: initialStartup ? this._marks.getDuration('code/willLoadMainBundle', 'code/didLoadMainBundle') : undefined,
ellapsedCrashReporter: initialStartup ? this._marks.getDuration('code/willStartCrashReporter', 'code/didStartCrashReporter') : undefined,
ellapsedMainServer: initialStartup ? this._marks.getDuration('code/willStartMainServer', 'code/didStartMainServer') : undefined,
ellapsedWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateWindow', 'code/didCreateWindow') : undefined,
ellapsedWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateCodeWindow', 'code/didCreateCodeWindow') : undefined,
ellapsedWindowRestoreState: initialStartup ? this._marks.getDuration('code/willRestoreCodeWindowState', 'code/didRestoreCodeWindowState') : undefined,
ellapsedBrowserWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateCodeBrowserWindow', 'code/didCreateCodeBrowserWindow') : undefined,
ellapsedWindowMaximize: initialStartup ? this._marks.getDuration('code/willMaximizeCodeWindow', 'code/didMaximizeCodeWindow') : undefined,
ellapsedWindowLoad: initialStartup ? this._marks.getDuration('code/mainAppReady', 'code/willOpenNewWindow') : undefined,
ellapsedWindowLoadToRequire: this._marks.getDuration('code/willOpenNewWindow', 'code/willLoadWorkbenchMain'),
ellapsedRequire: this._marks.getDuration('code/willLoadWorkbenchMain', 'code/didLoadWorkbenchMain'),