Skip to content

Commit

Permalink
perf(Trace): optimise getTotalTimeDurationInMillis function to push t…
Browse files Browse the repository at this point in the history
…o an array instead of concat arrays. (#1774)

* Thanks @infinity-naveen for your contribution 🎉
  • Loading branch information
infinity-naveen committed Sep 1, 2023
1 parent 3f494f8 commit 6ecde97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/transaction/trace/index.js
Expand Up @@ -218,13 +218,13 @@ Trace.prototype.getTotalTimeDurationInMillis = function getTotalTimeDurationInMi
if (this.root.children.length === 0) {
return 0
}
let segments = this.root.getChildren()
const segments = this.root.getChildren()
let totalTimeInMillis = 0

while (segments.length !== 0) {
const segment = segments.pop()
totalTimeInMillis += segment.getExclusiveDurationInMillis()
segments = segments.concat(segment.getChildren())
segment.getChildren().forEach((childSegment) => segments.push(childSegment))
}

if (!this.transaction.isActive()) {
Expand Down

0 comments on commit 6ecde97

Please sign in to comment.