File tree Expand file tree Collapse file tree 2 files changed +21
-15
lines changed
Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Original file line number Diff line number Diff line change @@ -340,19 +340,6 @@ func TestFlamegraphAggregation(t *testing.T) {
340340 SumSelfTime : 50 ,
341341 Count : 5 ,
342342 },
343- {
344- Name : "b" ,
345- Package : "test.package" ,
346- Fingerprint : 2430275455 ,
347- InApp : true ,
348- P75 : 40 ,
349- P95 : 40 ,
350- P99 : 40 ,
351- Avg : 35 ,
352- Sum : 70 ,
353- SumSelfTime : 20 ,
354- Count : 7 ,
355- },
356343 {
357344 Name : "a" ,
358345 Package : "test.package" ,
@@ -366,6 +353,19 @@ func TestFlamegraphAggregation(t *testing.T) {
366353 SumSelfTime : 20 ,
367354 Count : 9 ,
368355 },
356+ {
357+ Name : "b" ,
358+ Package : "test.package" ,
359+ Fingerprint : 2430275455 ,
360+ InApp : true ,
361+ P75 : 40 ,
362+ P95 : 40 ,
363+ P99 : 40 ,
364+ Avg : 35 ,
365+ Sum : 70 ,
366+ SumSelfTime : 20 ,
367+ Count : 7 ,
368+ },
369369 },
370370 },
371371 {
Original file line number Diff line number Diff line change @@ -100,7 +100,10 @@ func (ma *Aggregator) ToMetrics() []examples.FunctionMetrics {
100100 })
101101 }
102102 sort .Slice (metrics , func (i , j int ) bool {
103- return metrics [i ].SumSelfTime > metrics [j ].SumSelfTime
103+ if metrics [i ].SumSelfTime != metrics [j ].SumSelfTime {
104+ return metrics [i ].SumSelfTime > metrics [j ].SumSelfTime
105+ }
106+ return metrics [i ].Sum > metrics [j ].Sum
104107 })
105108 if len (metrics ) > int (ma .MaxUniqueFunctions ) {
106109 metrics = metrics [:ma .MaxUniqueFunctions ]
@@ -172,7 +175,10 @@ func mergeAndSortFunctions(
172175
173176 // sort the list in descending order, and take the top N results
174177 sort .SliceStable (functionsList , func (i , j int ) bool {
175- return functionsList [i ].SumSelfTimeNS > functionsList [j ].SumSelfTimeNS
178+ if functionsList [i ].SumSelfTimeNS != functionsList [j ].SumSelfTimeNS {
179+ return functionsList [i ].SumSelfTimeNS > functionsList [j ].SumSelfTimeNS
180+ }
181+ return functionsList [i ].SumDurationNS > functionsList [j ].SumDurationNS
176182 })
177183
178184 return functionsList
You can’t perform that action at this time.
0 commit comments