Skip to content

Commit 7c1dd74

Browse files
committed
Add reporting of input latency measurements
1 parent c1fa901 commit 7c1dd74

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/vs/workbench/contrib/performance/browser/inputLatencyContrib.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { inputLatency } from 'vs/base/browser/performance';
77
import { RunOnceScheduler } from 'vs/base/common/async';
88
import { Event } from 'vs/base/common/event';
99
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
10+
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1011
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1112
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1213

@@ -15,7 +16,8 @@ export class InputLatencyContrib extends Disposable implements IWorkbenchContrib
1516
private readonly _scheduler: RunOnceScheduler;
1617

1718
constructor(
18-
@IEditorService private readonly _editorService: IEditorService
19+
@IEditorService private readonly _editorService: IEditorService,
20+
@ITelemetryService private readonly _telemetryService: ITelemetryService
1921
) {
2022
super();
2123

@@ -24,9 +26,7 @@ export class InputLatencyContrib extends Disposable implements IWorkbenchContrib
2426
// everything, just somewhat randomly, and using an interval would utilize CPU when the
2527
// application is inactive.
2628
this._scheduler = this._register(new RunOnceScheduler(() => {
27-
const measurements = inputLatency.getAndClearMeasurements();
28-
console.log('measurements', measurements);
29-
// Listen for the next editor change
29+
this._logSamples();
3030
this._setupListener();
3131
}, 60000));
3232

@@ -36,4 +36,25 @@ export class InputLatencyContrib extends Disposable implements IWorkbenchContrib
3636
private _setupListener(): void {
3737
this._listener.value = Event.once(this._editorService.onDidActiveEditorChange)(() => this._scheduler.schedule());
3838
}
39+
40+
private _logSamples(): void {
41+
const measurements = inputLatency.getAndClearMeasurements();
42+
if (!measurements) {
43+
return;
44+
}
45+
46+
type PerformanceInputLatencyClassification = {
47+
owner: 'tyriar';
48+
comment: 'This is a set of samples of the time (in milliseconds) that various events took when typing in the editor';
49+
keydown: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The min, max and average time it took for the keydown event to execute.' };
50+
input: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The min, max and average time it took for the input event to execute.' };
51+
render: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The min, max and average time it took for the render animation frame to execute.' };
52+
total: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The min, max and average input latency.' };
53+
sampleCount: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The number of samples measured.' };
54+
};
55+
56+
type PerformanceInputLatencyEvent = inputLatency.IInputLatencyMeasurements;
57+
58+
this._telemetryService.publicLog2<PerformanceInputLatencyEvent, PerformanceInputLatencyClassification>('performance.inputLatency', measurements);
59+
}
3960
}

0 commit comments

Comments
 (0)