1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00

[PM-22544] Add Performance measurement tools (#15475)

Adds logService.mark and logService.measure which are wrappers around performance.mark and performance.measure with extra debug logging for more visibility outside the performance tool.
This commit is contained in:
Oscar Hinton
2025-07-17 15:03:57 +02:00
committed by GitHub
parent c4888efca7
commit 67d3035aa5
5 changed files with 86 additions and 14 deletions

View File

@@ -54,4 +54,43 @@ export class ConsoleLogService implements LogService {
break;
}
}
measure(
start: DOMHighResTimeStamp,
trackGroup: string,
track: string,
name?: string,
properties?: [string, any][],
): PerformanceMeasure {
const measureName = `[${track}]: ${name}`;
const measure = performance.measure(measureName, {
start: start,
detail: {
devtools: {
dataType: "track-entry",
track,
trackGroup,
properties,
},
},
});
this.info(`${measureName} took ${measure.duration}`, properties);
return measure;
}
mark(name: string): PerformanceMark {
const mark = performance.mark(name, {
detail: {
devtools: {
dataType: "marker",
},
},
});
this.info(mark.name, new Date().toISOString());
return mark;
}
}