mirror of
https://github.com/Microsoft/vscode
synced 2024-10-04 02:14:06 +00:00
perf - allow to log duration of 2 perf markers in web (#171152)
* perf - allow to log duration of 2 perf markers in web
* use `code/timeOrigin`
* 💄
This commit is contained in:
parent
05baad392b
commit
90609a93f7
|
@ -9,10 +9,17 @@ import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common
|
||||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||||
import { posix } from 'vs/base/common/path';
|
import { posix } from 'vs/base/common/path';
|
||||||
import { hash } from 'vs/base/common/hash';
|
import { hash } from 'vs/base/common/hash';
|
||||||
|
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||||
|
import { ITimerService } from 'vs/workbench/services/timer/browser/timerService';
|
||||||
|
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||||
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
|
|
||||||
class ResourcePerformanceMarks {
|
class ResourcePerformanceMarks {
|
||||||
|
|
||||||
constructor(@ITelemetryService telemetryService: ITelemetryService) {
|
constructor(
|
||||||
|
@ITelemetryService telemetryService: ITelemetryService,
|
||||||
|
@IEnvironmentService environmentService: IEnvironmentService
|
||||||
|
) {
|
||||||
|
|
||||||
type Entry = {
|
type Entry = {
|
||||||
hosthash: string;
|
hosthash: string;
|
||||||
|
@ -44,7 +51,33 @@ class ResourcePerformanceMarks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class StartupTimings {
|
||||||
|
constructor(
|
||||||
|
@ITimerService private readonly timerService: ITimerService,
|
||||||
|
@ILogService private readonly logService: ILogService,
|
||||||
|
@IBrowserWorkbenchEnvironmentService private readonly environmentService: IBrowserWorkbenchEnvironmentService
|
||||||
|
) {
|
||||||
|
this.logPerfMarks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async logPerfMarks(): Promise<void> {
|
||||||
|
if (!this.environmentService.profDurationMarkers) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.timerService.whenReady();
|
||||||
|
|
||||||
|
const [from, to] = this.environmentService.profDurationMarkers;
|
||||||
|
this.logService.info(`[perf] from '${from}' to '${to}': ${this.timerService.getDuration(from, to)}ms`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench).registerWorkbenchContribution(
|
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench).registerWorkbenchContribution(
|
||||||
ResourcePerformanceMarks,
|
ResourcePerformanceMarks,
|
||||||
LifecyclePhase.Eventually
|
LifecyclePhase.Eventually
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench).registerWorkbenchContribution(
|
||||||
|
StartupTimings,
|
||||||
|
LifecyclePhase.Eventually
|
||||||
|
);
|
||||||
|
|
|
@ -53,6 +53,7 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi
|
||||||
if (logLevelFromPayload) {
|
if (logLevelFromPayload) {
|
||||||
return logLevelFromPayload.split(',').find(entry => !EXTENSION_IDENTIFIER_WITH_LOG_REGEX.test(entry));
|
return logLevelFromPayload.split(',').find(entry => !EXTENSION_IDENTIFIER_WITH_LOG_REGEX.test(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.options.developmentOptions?.logLevel !== undefined ? LogLevelToString(this.options.developmentOptions?.logLevel) : undefined;
|
return this.options.developmentOptions?.logLevel !== undefined ? LogLevelToString(this.options.developmentOptions?.logLevel) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +67,27 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi
|
||||||
result.push([matches[1], matches[2]]);
|
result.push([matches[1], matches[2]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.length ? result : undefined;
|
return result.length ? result : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.options.developmentOptions?.extensionLogLevel !== undefined ? this.options.developmentOptions?.extensionLogLevel.map(([extension, logLevel]) => ([extension, LogLevelToString(logLevel)])) : undefined;
|
return this.options.developmentOptions?.extensionLogLevel !== undefined ? this.options.developmentOptions?.extensionLogLevel.map(([extension, logLevel]) => ([extension, LogLevelToString(logLevel)])) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get profDurationMarkers(): string[] | undefined {
|
||||||
|
const profDurationMarkersFromPayload = this.payload?.get('profDurationMarkers');
|
||||||
|
if (profDurationMarkersFromPayload) {
|
||||||
|
const result: string[] = [];
|
||||||
|
for (const entry of profDurationMarkersFromPayload.split(',')) {
|
||||||
|
result.push(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.length === 2 ? result : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
get windowLogsPath(): URI { return this.logsHome; }
|
get windowLogsPath(): URI { return this.logsHome; }
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ export interface IWorkbenchEnvironmentService extends IEnvironmentService {
|
||||||
readonly debugRenderer: boolean;
|
readonly debugRenderer: boolean;
|
||||||
readonly logExtensionHostCommunication?: boolean;
|
readonly logExtensionHostCommunication?: boolean;
|
||||||
readonly enableSmokeTestDriver?: boolean;
|
readonly enableSmokeTestDriver?: boolean;
|
||||||
|
readonly profDurationMarkers?: string[];
|
||||||
|
|
||||||
// --- Editors to open
|
// --- Editors to open
|
||||||
readonly filesToOpenOrCreate?: IPath[] | undefined;
|
readonly filesToOpenOrCreate?: IPath[] | undefined;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
|
||||||
import { ViewContainerLocation } from 'vs/workbench/common/views';
|
import { ViewContainerLocation } from 'vs/workbench/common/views';
|
||||||
import { StopWatch } from 'vs/base/common/stopwatch';
|
import { StopWatch } from 'vs/base/common/stopwatch';
|
||||||
import { TelemetryTrustedValue } from 'vs/platform/telemetry/common/telemetryUtils';
|
import { TelemetryTrustedValue } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||||
|
import { isWeb } from 'vs/base/common/platform';
|
||||||
|
|
||||||
/* __GDPR__FRAGMENT__
|
/* __GDPR__FRAGMENT__
|
||||||
"IMemoryInfo" : {
|
"IMemoryInfo" : {
|
||||||
|
@ -619,7 +620,12 @@ export abstract class AbstractTimerService implements ITimerService {
|
||||||
|
|
||||||
private async _computeStartupMetrics(): Promise<IStartupMetrics> {
|
private async _computeStartupMetrics(): Promise<IStartupMetrics> {
|
||||||
const initialStartup = this._isInitialStartup();
|
const initialStartup = this._isInitialStartup();
|
||||||
const startMark = initialStartup ? 'code/didStartMain' : 'code/willOpenNewWindow';
|
let startMark: string;
|
||||||
|
if (isWeb) {
|
||||||
|
startMark = 'code/timeOrigin';
|
||||||
|
} else {
|
||||||
|
startMark = initialStartup ? 'code/didStartMain' : 'code/willOpenNewWindow';
|
||||||
|
}
|
||||||
|
|
||||||
const activeViewlet = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
|
const activeViewlet = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
|
||||||
const activePanel = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel);
|
const activePanel = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel);
|
||||||
|
|
Loading…
Reference in a new issue