提交 a44cbeec 编写于 作者: J Johannes Rieken

debt - more timer migration

上级 16874c18
......@@ -26,6 +26,8 @@ export function getEntries(type: 'mark' | 'measure'): PerformanceEntry[];
export function getEntry(type: 'mark' | 'measure', name: string): PerformanceEntry;
export function getDuration(from: string, to: string): number;
type ExportData = any[];
export function importEntries(data: ExportData): void;
export function exportEntries(): ExportData;
......@@ -67,6 +67,25 @@ define([], function () {
}
}
function getDuration(from, to) {
const entries = global._performanceEntries;
let name = from;
let startTime = 0;
for (let i = 0; i < entries.length; i += 4) {
if (entries[i + 1] === name) {
if (name === from) {
// found `from` (start of interval)
name = to;
startTime = entries[i + 2];
} else {
// from `to` (end of interval)
return entries[i + 2] - startTime;
}
}
}
return 0;
}
function mark(name) {
global._performanceEntries.push('mark', name, _now(), 0);
if (typeof console.timeStamp === 'function') {
......@@ -118,6 +137,7 @@ define([], function () {
time: time,
getEntries: getEntries,
getEntry: getEntry,
getDuration: getDuration,
importEntries: importEntries,
exportEntries: exportEntries
};
......
......@@ -179,13 +179,13 @@ function main() {
windowLoad: configuration.perfWindowLoadTime
};
const workbenchMainClock = perf.time('loadWorkbenchMain');
perf.mark('willLoadWorkbenchMain');
require([
'vs/workbench/workbench.main',
'vs/nls!vs/workbench/workbench.main',
'vs/css!vs/workbench/workbench.main'
], function () {
workbenchMainClock.stop();
perf.mark('didLoadWorkbenchMain');
process.lazyEnv.then(function () {
perf.mark('main/startup');
......
......@@ -252,8 +252,6 @@ export class WorkbenchShell {
// Telemetry: startup metrics
this.timerService.workbenchStarted = Date.now();
this.timerService.restoreEditorsDuration = info.restoreEditorsDuration;
this.timerService.restoreViewletDuration = info.restoreViewletDuration;
this.extensionService.whenInstalledExtensionsRegistered().done(() => {
/* __GDPR__
"startupTime" : {
......
......@@ -15,8 +15,7 @@ import DOM = require('vs/base/browser/dom');
import { Builder, $ } from 'vs/base/browser/builder';
import { Delayer, RunOnceScheduler } from 'vs/base/common/async';
import * as browser from 'vs/base/browser/browser';
import { StopWatch } from 'vs/base/common/stopwatch';
import { time } from 'vs/base/common/performance';
import * as perf from 'vs/base/common/performance';
import errors = require('vs/base/common/errors');
import { BackupFileService } from 'vs/workbench/services/backup/node/backupFileService';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
......@@ -120,8 +119,6 @@ interface IZenModeSettings {
export interface IWorkbenchStartedInfo {
customKeybindingsCount: number;
restoreViewletDuration: number;
restoreEditorsDuration: number;
pinnedViewlets: string[];
restoredViewlet: string;
restoredEditors: string[];
......@@ -319,8 +316,7 @@ export class Workbench implements IPartService {
const restorePromises: TPromise<any>[] = [];
// Restore Editors
const editorRestoreStopWatch = StopWatch.create();
const editorRestoreClock = time('restore:editors');
perf.mark('willRestoreEditors');
const restoredEditors: string[] = [];
restorePromises.push(this.resolveEditorsToOpen().then(inputs => {
......@@ -337,8 +333,7 @@ export class Workbench implements IPartService {
return editorOpenPromise.then(editors => {
this.handleEditorBackground(); // make sure we show the proper background in the editor area
editorRestoreClock.stop();
editorRestoreStopWatch.stop();
perf.mark('didRestoreEditors');
for (const editor of editors) {
if (editor) {
......@@ -353,7 +348,6 @@ export class Workbench implements IPartService {
}));
// Restore Sidebar
let viewletRestoreStopWatch: StopWatch;
let viewletIdToRestore: string;
if (!this.sideBarHidden) {
this.sideBarVisibleContext.set(true);
......@@ -366,11 +360,9 @@ export class Workbench implements IPartService {
viewletIdToRestore = this.viewletService.getDefaultViewletId();
}
viewletRestoreStopWatch = StopWatch.create();
const viewletRestoreClock = time('restore:viewlet');
perf.mark('willRestoreViewlet');
restorePromises.push(this.viewletService.openViewlet(viewletIdToRestore).then(() => {
viewletRestoreStopWatch.stop();
viewletRestoreClock.stop();
perf.mark('didRestoreViewlet');
}));
}
......@@ -395,8 +387,6 @@ export class Workbench implements IPartService {
return {
customKeybindingsCount: this.keybindingService.customKeybindingsCount(),
restoreViewletDuration: viewletRestoreStopWatch ? Math.round(viewletRestoreStopWatch.elapsed()) : 0,
restoreEditorsDuration: Math.round(editorRestoreStopWatch.elapsed()),
pinnedViewlets: this.activitybarPart.getPinned(),
restoredViewlet: viewletIdToRestore,
restoredEditors
......
......@@ -104,8 +104,5 @@ export interface ITimerService extends IInitData {
beforeExtensionLoad: number;
afterExtensionLoad: number;
restoreViewletDuration: number;
restoreEditorsDuration: number;
readonly startupMetrics: IStartupMetrics;
}
......@@ -29,10 +29,6 @@ export class TimerService implements ITimerService {
public beforeExtensionLoad: number;
public afterExtensionLoad: number;
public restoreViewletDuration: number;
public restoreEditorsDuration: number;
private _startupMetrics: IStartupMetrics;
constructor(initData: IInitData, private isEmptyWorkbench: boolean) {
......@@ -91,11 +87,11 @@ export class TimerService implements ITimerService {
timers: {
ellapsedExtensions: this.afterExtensionLoad - this.beforeExtensionLoad,
ellapsedExtensionsReady: this.afterExtensionLoad - start,
ellapsedRequire: perf.getEntry('measure', 'loadWorkbenchMain').duration,
ellapsedViewletRestore: this.restoreViewletDuration,
ellapsedEditorRestore: this.restoreEditorsDuration,
ellapsedRequire: perf.getDuration('willLoadWorkbenchMain', 'didLoadWorkbenchMain'),
ellapsedEditorRestore: perf.getDuration('willRestoreEditors', 'didRestoreEditors'),
ellapsedViewletRestore: perf.getDuration('willRestoreViewlet', 'didRestoreViewlet'),
ellapsedWorkbench: this.workbenchStarted - this.beforeWorkbenchOpen,
ellapsedWindowLoadToRequire: perf.getEntry('mark', 'loadWorkbenchMain/start').startTime - this.windowLoad,
ellapsedWindowLoadToRequire: perf.getEntry('mark', 'willLoadWorkbenchMain').startTime - this.windowLoad,
ellapsedTimersToTimersComputed: Date.now() - now
},
platform,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册