timer mark sources must not be unique, fixes https://github.com/microsoft/vscode/issues/112708

This commit is contained in:
Johannes Rieken
2020-12-17 09:10:26 +01:00
parent 834488bd7a
commit a09cbd1b11

View File

@@ -358,13 +358,10 @@ export const ITimerService = createDecorator<ITimerService>('timerService');
class PerfMarks {
private readonly _entries = new Map<string, perf.PerformanceMark[]>();
private readonly _entries: [string, perf.PerformanceMark[]][] = [];
setMarks(source: string, entries: perf.PerformanceMark[]): void {
if (this._entries.has(source)) {
throw new Error(`${source} EXISTS already`);
}
this._entries.set(source, entries);
this._entries.push([source, entries]);
}
getDuration(from: string, to: string): number {
@@ -380,17 +377,17 @@ class PerfMarks {
}
private _findEntry(name: string): perf.PerformanceMark | void {
for (let entries of this._entries.values()) {
for (let i = entries.length - 1; i >= 0; i--) {
if (entries[i].name === name) {
return entries[i];
for (let [, marks] of this._entries) {
for (let i = marks.length - 1; i >= 0; i--) {
if (marks[i].name === name) {
return marks[i];
}
}
}
}
getEntries() {
return Array.from(this._entries);
return this._entries.slice(0);
}
}