Skip to content

Commit

Permalink
chore: add verbose logging for errors in startup perf script
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 committed May 12, 2020
1 parent 2099a54 commit ef9a0a8
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
import { ILifecycleService, StartupKind, StartupKindToString } from 'vs/platform/lifecycle/common/lifecycle';
import product from 'vs/platform/product/common/product';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IUpdateService } from 'vs/platform/update/common/update';
Expand Down Expand Up @@ -41,9 +41,9 @@ export class StartupTimings implements IWorkbenchContribution {
}

private async _report() {
const isStandardStartup = await this._isStandardStartup();
const standardStartupError = await this._isStandardStartup();
this._reportStartupTimes().catch(onUnexpectedError);
this._appendStartupTimes(isStandardStartup).catch(onUnexpectedError);
this._appendStartupTimes(standardStartupError).catch(onUnexpectedError);
this._reportPerfTicks();
}

Expand All @@ -60,7 +60,7 @@ export class StartupTimings implements IWorkbenchContribution {
this._telemetryService.publicLog('startupTimeVaried', metrics);
}

private async _appendStartupTimes(isStandardStartup: boolean) {
private async _appendStartupTimes(standardStartupError: string | undefined) {
const appendTo = this._envService.args['prof-append-timers'];
if (!appendTo) {
// nothing to do
Expand All @@ -73,7 +73,7 @@ export class StartupTimings implements IWorkbenchContribution {
this._timerService.startupMetrics,
timeout(15000), // wait: cached data creation, telemetry sending
]).then(([startupMetrics]) => {
return promisify(appendFile)(appendTo, `${startupMetrics.ellapsed}\t${product.nameShort}\t${(product.commit || '').slice(0, 10) || '0000000000'}\t${sessionId}\t${isStandardStartup ? 'standard_start' : 'NO_standard_start'}\n`);
return promisify(appendFile)(appendTo, `${startupMetrics.ellapsed}\t${product.nameShort}\t${(product.commit || '').slice(0, 10) || '0000000000'}\t${sessionId}\t${standardStartupError === undefined ? 'standard_start' : 'NO_standard_start : ' + standardStartupError}\n`);
}).then(() => {
this._electronService.quit();
}).catch(err => {
Expand All @@ -82,37 +82,42 @@ export class StartupTimings implements IWorkbenchContribution {
});
}

private async _isStandardStartup(): Promise<boolean> {
private async _isStandardStartup(): Promise<string | undefined> {
// check for standard startup:
// * new window (no reload)
// * just one window
// * explorer viewlet visible
// * one text editor (not multiple, not webview, welcome etc...)
// * cached data present (not rejected, not created)
if (this._lifecycleService.startupKind !== StartupKind.NewWindow) {
return false;
return StartupKindToString(this._lifecycleService.startupKind);
}
if (await this._electronService.getWindowCount() !== 1) {
return false;
const windowCount = await this._electronService.getWindowCount();
if (windowCount !== 1) {
return 'Expected window count : 1, Actual : ' + windowCount;
}
const activeViewlet = this._viewletService.getActiveViewlet();
if (!activeViewlet || activeViewlet.getId() !== files.VIEWLET_ID) {
return false;
return 'Explorer viewlet not visible';
}
const visibleEditorPanes = this._editorService.visibleEditorPanes;
if (visibleEditorPanes.length !== 1 || !isCodeEditor(visibleEditorPanes[0].getControl())) {
return false;
if (visibleEditorPanes.length !== 1) {
return 'Expected text editor count : 1, Actual : ' + visibleEditorPanes.length;
}
if (this._panelService.getActivePanel()) {
return false;
if (!isCodeEditor(visibleEditorPanes[0].getControl())) {
return 'Active editor is not a text editor';
}
const activePanel = this._panelService.getActivePanel();
if (activePanel) {
return 'Current active panel : ' + this._panelService.getPanel(activePanel.getId())?.name;
}
if (!didUseCachedData()) {
return false;
return 'Either cache data is rejected or not created';
}
if (!await this._updateService.isLatestVersion()) {
return false;
return 'Not on latest version, updates available';
}
return true;
return undefined;
}

private _reportPerfTicks(): void {
Expand Down

0 comments on commit ef9a0a8

Please sign in to comment.