Skip to content

Commit 916566d

Browse files
committed
Small fix for P-CPU MHz freq on some chips
1 parent 628a742 commit 916566d

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

main.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,10 @@ func setupGrid() {
180180
grid = ui.NewGrid()
181181
grid.Set(
182182
ui.NewRow(1.0/2, // This row now takes half the height of the grid
183-
ui.NewCol(1.0/2, ui.NewRow(1.0/2, cpu1Gauge), ui.NewCol(1.0, ui.NewRow(1.0, cpu2Gauge))),
184-
ui.NewCol(1.0/2, ui.NewRow(1.0/2, gpuGauge), ui.NewCol(1.0, ui.NewRow(1.0, processList))), // ui.NewCol(1.0/2, ui.NewRow(1.0, ProcessInfo)), // ProcessInfo spans this entire column
183+
ui.NewCol(1.0/2, ui.NewRow(1.0/2, cpu1Gauge), ui.NewCol(1.0, ui.NewRow(1.0, cpu2Gauge))), ui.NewCol(1.0/2, ui.NewRow(1.0/2, gpuGauge), ui.NewCol(1.0, ui.NewRow(1.0, processList))), // ui.NewCol(1.0/2, ui.NewRow(1.0, ProcessInfo)), // ProcessInfo spans this entire column
185184
),
186185
ui.NewRow(1.0/4,
187-
ui.NewCol(1.0/6, modelText),
188-
ui.NewCol(1.0/3, NetworkInfo),
189-
ui.NewCol(1.0/4, PowerChart),
190-
ui.NewCol(1.0/4, TotalPowerChart),
186+
ui.NewCol(1.0/6, modelText), ui.NewCol(1.0/3, NetworkInfo), ui.NewCol(1.0/4, PowerChart), ui.NewCol(1.0/4, TotalPowerChart),
191187
),
192188
ui.NewRow(1.0/4,
193189
ui.NewCol(1.0, memoryGauge),
@@ -200,8 +196,7 @@ func switchGridLayout() {
200196
newGrid := ui.NewGrid()
201197
newGrid.Set(
202198
ui.NewRow(1.0/4,
203-
ui.NewCol(1.0/2, ui.NewRow(1.0, cpu1Gauge)),
204-
ui.NewCol(1.0/2, ui.NewRow(1.0, cpu2Gauge)),
199+
ui.NewCol(1.0/2, ui.NewRow(1.0, cpu1Gauge)), ui.NewCol(1.0/2, ui.NewRow(1.0, cpu2Gauge)),
205200
),
206201
ui.NewRow(2.0/4,
207202
ui.NewCol(1.0/2,
@@ -214,9 +209,7 @@ func switchGridLayout() {
214209
ui.NewCol(1.0/2, processList),
215210
),
216211
ui.NewRow(1.0/4,
217-
ui.NewCol(3.0/6, memoryGauge),
218-
ui.NewCol(1.0/6, modelText),
219-
ui.NewCol(2.0/6, NetworkInfo),
212+
ui.NewCol(3.0/6, memoryGauge), ui.NewCol(1.0/6, modelText), ui.NewCol(2.0/6, NetworkInfo),
220213
),
221214
)
222215
termWidth, termHeight := ui.TerminalDimensions()
@@ -227,14 +220,10 @@ func switchGridLayout() {
227220
newGrid := ui.NewGrid()
228221
newGrid.Set(
229222
ui.NewRow(1.0/2,
230-
ui.NewCol(1.0/2, ui.NewRow(1.0/2, cpu1Gauge), ui.NewCol(1.0, ui.NewRow(1.0, cpu2Gauge))),
231-
ui.NewCol(1.0/2, ui.NewRow(1.0/2, gpuGauge), ui.NewCol(1.0, ui.NewRow(1.0, processList))),
223+
ui.NewCol(1.0/2, ui.NewRow(1.0/2, cpu1Gauge), ui.NewCol(1.0, ui.NewRow(1.0, cpu2Gauge))), ui.NewCol(1.0/2, ui.NewRow(1.0/2, gpuGauge), ui.NewCol(1.0, ui.NewRow(1.0, processList))),
232224
),
233225
ui.NewRow(1.0/4,
234-
ui.NewCol(1.0/4, modelText),
235-
ui.NewCol(1.0/4, NetworkInfo),
236-
ui.NewCol(1.0/4, PowerChart),
237-
ui.NewCol(1.0/4, TotalPowerChart),
226+
ui.NewCol(1.0/4, modelText), ui.NewCol(1.0/4, NetworkInfo), ui.NewCol(1.0/4, PowerChart), ui.NewCol(1.0/4, TotalPowerChart),
238227
),
239228
ui.NewRow(1.0/4,
240229
ui.NewCol(1.0, memoryGauge),
@@ -877,6 +866,19 @@ func parseCPUMetrics(powermetricsOutput string, cpuMetrics CPUMetrics) CPUMetric
877866
if combinedPower, ok := processor["combined_power"].(float64); ok {
878867
cpuMetrics.PackageW = float64(combinedPower) / 1000
879868
}
869+
if _, exists := cpuMetricDict["P-Cluster_freq_Mhz"]; !exists {
870+
var totalFreq float64
871+
var clusterCount int
872+
for i := 0; i <= 50; i++ {
873+
if freq, ok := cpuMetricDict[fmt.Sprintf("P-Cluster%d_freq_Mhz", i)].(int); ok {
874+
totalFreq += float64(freq)
875+
clusterCount++
876+
}
877+
}
878+
if clusterCount > 0 {
879+
cpuMetrics.PClusterFreqMHz = int(totalFreq / float64(clusterCount))
880+
}
881+
}
880882
return cpuMetrics
881883
}
882884

0 commit comments

Comments
 (0)