Skip to content

Commit f6f944e

Browse files
authored
report perf marks whenever delivered (microsoft#165250)
1 parent ba9be48 commit f6f944e

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/vs/workbench/services/timer/browser/timerService.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,9 @@ export abstract class AbstractTimerService implements ITimerService {
547547
setPerformanceMarks(source: string, marks: perf.PerformanceMark[]): void {
548548
// Perf marks are a shared resource because anyone can generate them
549549
// and because of that we only accept marks that start with 'code/'
550-
this._marks.setMarks(source, marks.filter(mark => mark.name.startsWith('code/')));
550+
const codeMarks = marks.filter(mark => mark.name.startsWith('code/'));
551+
this._marks.setMarks(source, codeMarks);
552+
this._reportPerformanceMarks(source, codeMarks);
551553
}
552554

553555
getPerformanceMarks(): [source: string, marks: readonly perf.PerformanceMark[]][] {
@@ -565,34 +567,30 @@ export abstract class AbstractTimerService implements ITimerService {
565567
}
566568
*/
567569
this._telemetryService.publicLog('startupTimeVaried', metrics);
570+
}
568571

569-
572+
private _reportPerformanceMarks(source: string, marks: perf.PerformanceMark[]) {
570573
// report raw timers as telemetry. each mark is send a separate telemetry
571574
// event and it is "normalized" to a relative timestamp where the first mark
572575
// defines the start
573-
for (const [source, marks] of this.getPerformanceMarks()) {
574-
type Mark = { source: string; name: string; relativeStartTime: number; startTime: number };
575-
type MarkClassification = {
576-
owner: 'jrieken';
577-
comment: 'Information about a performance marker';
578-
source: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Where this marker was generated, e.g main, renderer, extension host' };
579-
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The name of this marker (as defined in source code)' };
580-
relativeStartTime: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'The duration between the previous and this marker' };
581-
startTime: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'The absolute timestamp (unix time)' };
582-
};
583-
584-
let lastMark: perf.PerformanceMark = marks[0];
585-
for (const mark of marks) {
586-
const delta = mark.startTime - lastMark.startTime;
587-
this._telemetryService.publicLog2<Mark, MarkClassification>('startup.timer.mark', {
588-
source,
589-
name: mark.name,
590-
relativeStartTime: delta,
591-
startTime: mark.startTime
592-
});
593-
lastMark = mark;
594-
}
576+
577+
type Mark = { source: string; name: string; startTime: number };
578+
type MarkClassification = {
579+
owner: 'jrieken';
580+
comment: 'Information about a performance marker';
581+
source: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Where this marker was generated, e.g main, renderer, extension host' };
582+
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The name of this marker (as defined in source code)' };
583+
startTime: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'The absolute timestamp (unix time)' };
584+
};
585+
586+
for (const mark of marks) {
587+
this._telemetryService.publicLog2<Mark, MarkClassification>('startup.timer.mark', {
588+
source,
589+
name: mark.name,
590+
startTime: mark.startTime
591+
});
595592
}
593+
596594
}
597595

598596
private async _computeStartupMetrics(): Promise<IStartupMetrics> {

0 commit comments

Comments
 (0)