certinia / debug-log-analyzer

Salesforce Apex debug log analyzer for Visual Studio Code - Visualize code execution via a Flame chart and identify performance and SOQL/DML problems via Method and Database analysis
https://marketplace.visualstudio.com/items?itemName=financialforce.lana
BSD 3-Clause "New" or "Revised" License
82 stars 18 forks source link

bug: Total Total time in the analysis tree is overstated #526

Open petehale opened 2 months ago

petehale commented 2 months ago

Summary

When I am looking at the Analyze tab I see the times associated with the debug run; Self Time and Total Time. Total time represents the total time spent in each of the table items.

The Total line is summing the total time for each entry in the two time columns, leaving the sum of Total Time overstated.

Steps To Reproduce

  1. Run a a apex debug session
  2. Download log
  3. Open Analyze tab
  4. Expected result

I believe the Total Total Time should be removed, as it is meaning less.

Actual result

Overstated Total Time sum

VS Code Version: Version: 1.90.2 Commit: 5437499feb04f7a586f677b155b039bc2b3669eb Date: 2024-06-18T22:37:41.291Z (2 days ago) Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin x64 23.5.0

Log Analyzer Extension Version: 1.14.1

lcottercertinia commented 2 months ago

Right now we have it setup to just sum all the totals, which leads to double counting. It would be more accurate to just show the largest number. That would work as long as only have one EXECUTION_STARTED and have not filtered out that event type.

A better approach would be to collect the stacks and only sum the unique entries e.g If we have an analysis like this

methodA: 5s methodB: 3s methodC: 2s

Sibling Methods The three methods are at the same level directly called from EXECUTION_STARTED. All 3 should be summed as they are in different stacks.

Total: 10s

Child Methods

methodB is a child of methodA and methodC is a sibling of methodA. we first add methodA to the total but the total for methodB has already been accounted by including methodA so we skip it and any other children of methodA. methodC is in a unique stack and needs to be added to the total.

Total: 7s

I will see when we can fit this in.