@@ -1370,24 +1370,21 @@ func c6TelemetryTableHTMLRenderer(tableValues TableValues, targetName string) st
13701370}
13711371
13721372// instructionTelemetryTableHTMLRenderer renders instruction set usage statistics
1373- // These categories are included even if all values are zero:
1374- //
1375- // "SSE", "AVX", "AVX2", "AVX512", "AMX_TILE"
1376- //
1377- // Other categories are only included if they have non-zero values.
1378- // Other categories are hidden by default.
1379- //
13801373// Each category is a separate dataset within the chart.
1374+ // Categories with zero total usage are hidden by default.
13811375func instructionTelemetryTableHTMLRenderer (tableValues TableValues , targetname string ) string {
1382- //alwaysIncludeCategories := []string{"SSE", "AVX", "AVX2", "AVX512", "AMX_TILE"}
1383- data := [][]float64 {}
1384- datasetNames := []string {}
1385- var hiddenFlags []bool
1386- for _ , field := range tableValues .Fields [1 :] {
1376+ // Collect entries with their sums so we can sort per requirements
1377+ type instrEntry struct {
1378+ name string
1379+ points []float64
1380+ sum float64
1381+ }
1382+ entries := []instrEntry {}
1383+ for _ , field := range tableValues .Fields [1 :] { // skip timestamp field
13871384 points := []float64 {}
13881385 sum := 0.0
13891386 for _ , val := range field .Values {
1390- if val == "" {
1387+ if val == "" { // end of data for this category
13911388 break
13921389 }
13931390 stat , err := strconv .ParseFloat (val , 64 )
@@ -1398,18 +1395,32 @@ func instructionTelemetryTableHTMLRenderer(tableValues TableValues, targetname s
13981395 points = append (points , stat )
13991396 sum += stat
14001397 }
1401- if len (points ) > 0 {
1402- //include := sum > 0 || slices.Contains(alwaysIncludeCategories, field.Name)
1403- include := true
1404- if include {
1405- data = append (data , points )
1406- datasetNames = append (datasetNames , field .Name )
1407- // hidden if sum == 0 (which can only happen for 'always include' categories)
1408- hidden := sum == 0
1409- hiddenFlags = append (hiddenFlags , hidden )
1410- }
1398+ if len (points ) > 0 { // only include categories with at least one point
1399+ entries = append (entries , instrEntry {name : field .Name , points : points , sum : sum })
14111400 }
14121401 }
1402+ // Partition into non-zero and zero-sum groups
1403+ nonZero := []instrEntry {}
1404+ zero := []instrEntry {}
1405+ for _ , e := range entries {
1406+ if e .sum > 0 {
1407+ nonZero = append (nonZero , e )
1408+ } else {
1409+ zero = append (zero , e )
1410+ }
1411+ }
1412+ sort .Slice (nonZero , func (i , j int ) bool { return nonZero [i ].name < nonZero [j ].name })
1413+ sort .Slice (zero , func (i , j int ) bool { return zero [i ].name < zero [j ].name })
1414+ ordered := append (nonZero , zero ... )
1415+ data := make ([][]float64 , 0 , len (ordered ))
1416+ datasetNames := make ([]string , 0 , len (ordered ))
1417+ hiddenFlags := make ([]bool , 0 , len (ordered ))
1418+ for _ , e := range ordered {
1419+ data = append (data , e .points )
1420+ datasetNames = append (datasetNames , e .name )
1421+ // hide zero-sum categories by default
1422+ hiddenFlags = append (hiddenFlags , e .sum == 0 )
1423+ }
14131424 chartConfig := chartTemplateStruct {
14141425 ID : fmt .Sprintf ("%s%d" , tableValues .Name , util .RandUint (10000 )),
14151426 XaxisText : "Time" ,
0 commit comments