-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #547 from lukecotter/bug-analysis-total-time-overs…
…tated fix: analysis total time overstated
- Loading branch information
Showing
4 changed files
with
140 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
log-viewer/modules/components/analysis-view/column-calcs/CallStackSum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { LogLine } from '../../../parsers/ApexLogParser'; | ||
import { type Metric } from '../../AnalysisView.js'; | ||
|
||
export function callStackSum(_values: number[], data: Metric[], _calcParams: unknown) { | ||
const nodes: LogLine[] = []; | ||
for (const row of data) { | ||
Array.prototype.push.apply(nodes, row.nodes); | ||
} | ||
const allNodes = new Set<LogLine>(nodes); | ||
|
||
let total = 0; | ||
for (const node of nodes) { | ||
if (!_isChildOfOther(node, allNodes)) { | ||
total += node.duration.total; | ||
} | ||
} | ||
|
||
return total; | ||
} | ||
|
||
function _isChildOfOther(node: LogLine, filteredNodes: Set<LogLine>) { | ||
let parent = node.parent; | ||
while (parent) { | ||
if (filteredNodes.has(parent)) { | ||
return true; | ||
} | ||
parent = parent.parent; | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters