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

debt - more timer migration

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