Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/report/table_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ func getBucketSizesFromHex(hex string) ([]int, error) {
return bucketSizes, nil
}

// padFrequencies adds items to the frequencies slice until it reaches the desired length.
// The value of the added items is the same as the last item in the original slice.
func padFrequencies(freqs []int, desiredLength int) ([]int, error) {
if len(freqs) == 0 {
return nil, fmt.Errorf("cannot pad empty frequencies slice")
}
for len(freqs) < desiredLength {
freqs = append(freqs, freqs[len(freqs)-1])
}
return freqs, nil
}

// getSpecFrequencyBuckets
// returns slice of rows
// first row is header
Expand Down Expand Up @@ -304,6 +316,12 @@ func getSpecFrequencyBuckets(outputs map[string]script.ScriptOutput) ([][]string
freqs[i] = 0
}
}
if len(freqs) != len(bucketCoreCounts) {
freqs, err = padFrequencies(freqs, len(bucketCoreCounts))
if err != nil {
return nil, fmt.Errorf("failed to pad frequencies: %w", err)
}
}
for _, freq := range freqs {
// convert freq to GHz
freqf := float64(freq) / 10.0
Expand Down Expand Up @@ -339,6 +357,9 @@ func getSpecFrequencyBuckets(outputs map[string]script.ScriptOutput) ([][]string
if isaFreqs[0] == "0.0" {
continue
} else {
if i >= len(isaFreqs) {
return nil, fmt.Errorf("index out of range for isa frequencies")
}
row = append(row, isaFreqs[i])
}
}
Expand Down