mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 09:35:40 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
78
src/vs/workbench/services/timer/common/timerService.ts
Normal file
78
src/vs/workbench/services/timer/common/timerService.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const ITimerService = createDecorator<ITimerService>('timerService');
|
||||
|
||||
export interface IMemoryInfo {
|
||||
workingSetSize: number;
|
||||
peakWorkingSetSize: number;
|
||||
privateBytes: number;
|
||||
sharedBytes: number;
|
||||
}
|
||||
|
||||
export interface IStartupMetrics {
|
||||
version: number;
|
||||
ellapsed: number;
|
||||
timers: {
|
||||
ellapsedAppReady?: number;
|
||||
ellapsedWindowLoad?: number;
|
||||
ellapsedWindowLoadToRequire: number;
|
||||
ellapsedExtensions: number;
|
||||
ellapsedExtensionsReady: number;
|
||||
ellapsedRequire: number;
|
||||
ellapsedViewletRestore: number;
|
||||
ellapsedEditorRestore: number;
|
||||
ellapsedWorkbench: number;
|
||||
ellapsedTimersToTimersComputed: number;
|
||||
};
|
||||
timers2: { [name: string]: number };
|
||||
platform: string;
|
||||
release: string;
|
||||
arch: string;
|
||||
totalmem: number;
|
||||
freemem: number;
|
||||
meminfo: IMemoryInfo;
|
||||
cpus: { count: number; speed: number; model: string; };
|
||||
initialStartup: boolean;
|
||||
hasAccessibilitySupport: boolean;
|
||||
isVMLikelyhood: number;
|
||||
emptyWorkbench: boolean;
|
||||
loadavg: number[];
|
||||
}
|
||||
|
||||
export interface IInitData {
|
||||
start: number;
|
||||
|
||||
appReady: number;
|
||||
|
||||
windowLoad: number;
|
||||
|
||||
beforeLoadWorkbenchMain: number;
|
||||
afterLoadWorkbenchMain: number;
|
||||
|
||||
isInitialStartup: boolean;
|
||||
hasAccessibilitySupport: boolean;
|
||||
}
|
||||
|
||||
export interface ITimerService extends IInitData {
|
||||
_serviceBrand: any;
|
||||
|
||||
beforeDOMContentLoaded: number;
|
||||
afterDOMContentLoaded: number;
|
||||
|
||||
beforeWorkbenchOpen: number;
|
||||
workbenchStarted: number;
|
||||
|
||||
beforeExtensionLoad: number;
|
||||
afterExtensionLoad: number;
|
||||
|
||||
restoreViewletDuration: number;
|
||||
restoreEditorsDuration: number;
|
||||
|
||||
readonly startupMetrics: IStartupMetrics;
|
||||
}
|
||||
134
src/vs/workbench/services/timer/node/timerService.ts
Normal file
134
src/vs/workbench/services/timer/node/timerService.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { ITimerService, IStartupMetrics, IInitData, IMemoryInfo } from 'vs/workbench/services/timer/common/timerService';
|
||||
import { virtualMachineHint } from 'vs/base/node/id';
|
||||
import { ticks } from 'vs/base/node/startupTimers';
|
||||
|
||||
import * as os from 'os';
|
||||
|
||||
export class TimerService implements ITimerService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
public readonly start: number;
|
||||
public readonly appReady: number;
|
||||
public readonly windowLoad: number;
|
||||
|
||||
public readonly beforeLoadWorkbenchMain: number;
|
||||
public readonly afterLoadWorkbenchMain: number;
|
||||
|
||||
public readonly isInitialStartup: boolean;
|
||||
public readonly hasAccessibilitySupport: boolean;
|
||||
|
||||
public beforeDOMContentLoaded: number;
|
||||
public afterDOMContentLoaded: number;
|
||||
|
||||
public beforeWorkbenchOpen: number;
|
||||
public workbenchStarted: number;
|
||||
|
||||
public beforeExtensionLoad: number;
|
||||
public afterExtensionLoad: number;
|
||||
|
||||
public restoreViewletDuration: number;
|
||||
public restoreEditorsDuration: number;
|
||||
|
||||
|
||||
private _startupMetrics: IStartupMetrics;
|
||||
|
||||
constructor(initData: IInitData, private isEmptyWorkbench: boolean) {
|
||||
this.start = initData.start;
|
||||
this.appReady = initData.appReady;
|
||||
this.windowLoad = initData.windowLoad;
|
||||
|
||||
this.beforeLoadWorkbenchMain = initData.beforeLoadWorkbenchMain;
|
||||
this.afterLoadWorkbenchMain = initData.afterLoadWorkbenchMain;
|
||||
|
||||
this.isInitialStartup = initData.isInitialStartup;
|
||||
this.hasAccessibilitySupport = initData.hasAccessibilitySupport;
|
||||
}
|
||||
|
||||
get startupMetrics(): IStartupMetrics {
|
||||
if (!this._startupMetrics) {
|
||||
this._computeStartupMetrics();
|
||||
}
|
||||
return this._startupMetrics;
|
||||
}
|
||||
|
||||
public _computeStartupMetrics(): void {
|
||||
const now = Date.now();
|
||||
const initialStartup = !!this.isInitialStartup;
|
||||
const start = initialStartup ? this.start : this.windowLoad;
|
||||
|
||||
let totalmem: number;
|
||||
let freemem: number;
|
||||
let cpus: { count: number; speed: number; model: string; };
|
||||
let platform: string;
|
||||
let release: string;
|
||||
let arch: string;
|
||||
let loadavg: number[];
|
||||
let meminfo: IMemoryInfo;
|
||||
let isVMLikelyhood: number;
|
||||
|
||||
try {
|
||||
totalmem = os.totalmem();
|
||||
freemem = os.freemem();
|
||||
platform = os.platform();
|
||||
release = os.release();
|
||||
arch = os.arch();
|
||||
loadavg = os.loadavg();
|
||||
meminfo = process.getProcessMemoryInfo();
|
||||
|
||||
isVMLikelyhood = Math.round((virtualMachineHint.value() * 100));
|
||||
|
||||
const rawCpus = os.cpus();
|
||||
if (rawCpus && rawCpus.length > 0) {
|
||||
cpus = { count: rawCpus.length, speed: rawCpus[0].speed, model: rawCpus[0].model };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error); // be on the safe side with these hardware method calls
|
||||
}
|
||||
|
||||
// fill in startup timers we have until now
|
||||
const timers2: { [name: string]: number } = Object.create(null);
|
||||
for (const tick of ticks()) {
|
||||
timers2[tick.name] = tick.duration;
|
||||
}
|
||||
|
||||
this._startupMetrics = {
|
||||
version: 1,
|
||||
ellapsed: this.workbenchStarted - start,
|
||||
timers: {
|
||||
ellapsedExtensions: this.afterExtensionLoad - this.beforeExtensionLoad,
|
||||
ellapsedExtensionsReady: this.afterExtensionLoad - start,
|
||||
ellapsedRequire: this.afterLoadWorkbenchMain - this.beforeLoadWorkbenchMain,
|
||||
ellapsedViewletRestore: this.restoreViewletDuration,
|
||||
ellapsedEditorRestore: this.restoreEditorsDuration,
|
||||
ellapsedWorkbench: this.workbenchStarted - this.beforeWorkbenchOpen,
|
||||
ellapsedWindowLoadToRequire: this.beforeLoadWorkbenchMain - this.windowLoad,
|
||||
ellapsedTimersToTimersComputed: Date.now() - now
|
||||
},
|
||||
timers2,
|
||||
platform,
|
||||
release,
|
||||
arch,
|
||||
totalmem,
|
||||
freemem,
|
||||
meminfo,
|
||||
cpus,
|
||||
loadavg,
|
||||
initialStartup,
|
||||
isVMLikelyhood,
|
||||
hasAccessibilitySupport: !!this.hasAccessibilitySupport,
|
||||
emptyWorkbench: this.isEmptyWorkbench
|
||||
};
|
||||
|
||||
if (initialStartup) {
|
||||
this._startupMetrics.timers.ellapsedAppReady = this.appReady - this.start;
|
||||
this._startupMetrics.timers.ellapsedWindowLoad = this.windowLoad - this.appReady;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user