Skip to content

Commit

Permalink
perf: move the child duration aggregation to the aggregateTotals func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
lukecotter committed Jan 5, 2024
1 parent a0c09f1 commit 6e95904
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions log-viewer/modules/parsers/ApexLogParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export default class ApexLogParser {
rootMethod.setTimes();

this.insertPackageWrappers(rootMethod);

this.setNamespaces(rootMethod);
this.aggregateTotals([rootMethod]);
return rootMethod;
Expand Down Expand Up @@ -342,14 +341,13 @@ export default class ApexLogParser {
let i = nds.length;
while (i--) {
const parent = nds[i];
if (parent?.children) {
parent.children.forEach((child) => {
parent.dmlCount.total += child.dmlCount.total;
parent.soqlCount.total += child.soqlCount.total;
parent.totalThrownCount += child.totalThrownCount;
parent.rowCount.total += child.rowCount.total;
});
}
parent?.children.forEach((child) => {
parent.dmlCount.total += child.dmlCount.total;
parent.soqlCount.total += child.soqlCount.total;
parent.totalThrownCount += child.totalThrownCount;
parent.rowCount.total += child.rowCount.total;
parent.duration.self -= child.duration.total;
});
}
}
}
Expand Down Expand Up @@ -758,11 +756,7 @@ export class TimedNode extends LogLine {

recalculateDurations() {
if (this.exitStamp) {
const childDuration = this.children.reduce((accumulator, currentValue) => {
return accumulator + currentValue.duration.total;
}, 0);
this.duration.total = this.exitStamp - this.timestamp;
this.duration.self = this.duration.total - childDuration;
this.duration.total = this.duration.self = this.exitStamp - this.timestamp;
}
}
}
Expand Down

0 comments on commit 6e95904

Please sign in to comment.