Skip to content

Commit 4dbdb17

Browse files
committed
Dynamic max E cores, Pro manual parse calc
1 parent 30dbad2 commit 4dbdb17

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func parseCPUMetrics(powermetricsOutput string, cpuMetrics CPUMetrics, modelName
632632
var eClusterActiveSum, pClusterActiveSum, eClusterFreqSum, pClusterFreqSum float64
633633
var eClusterCount, pClusterCount, eClusterActiveTotal, pClusterActiveTotal, eClusterFreqTotal, pClusterFreqTotal int
634634

635-
if modelName == "Apple M3 Max" || modelName == "Apple M2 Max" || modelName == "Apple M4 Max" { // For the M3/M2/M4 Max, we need to manually parse the CPU Usage from the powermetrics output (as current bug in Apple's powermetrics)
635+
if modelName == "Apple M3 Max" || modelName == "Apple M2 Max" || modelName == "Apple M4 Max" || modelName == "Apple M1 Max" || modelName == "Apple M4 Pro" || modelName == "Apple M3 Pro" || modelName == "Apple M2 Pro" || modelName == "Apple M1 Pro" { // For the M3/M2/M4 Max/Pro, we need to manually parse the CPU Usage from the powermetrics output (as current bug in Apple's powermetrics)
636636
coreCounts := getCoreCounts()
637637
maxCoresP := coreCounts["hw.perflevel0.logicalcpu"]
638638
maxCoresE := coreCounts["hw.perflevel1.logicalcpu"]
@@ -643,7 +643,7 @@ func parseCPUMetrics(powermetricsOutput string, cpuMetrics CPUMetrics, modelName
643643
matches := re.FindStringSubmatch(powermetricsOutput)
644644
if len(matches) > 1 {
645645
activeResidency, _ := strconv.ParseFloat(matches[1], 64)
646-
if i <= 3 {
646+
if i <= maxCoresE {
647647
eClusterActiveSum += activeResidency
648648
eClusterCount++
649649
} else {
@@ -657,7 +657,7 @@ func parseCPUMetrics(powermetricsOutput string, cpuMetrics CPUMetrics, modelName
657657
matches := fre.FindStringSubmatch(powermetricsOutput)
658658
if len(matches) > 1 {
659659
activeFreq, _ := strconv.ParseFloat(matches[1], 64)
660-
if i <= 3 {
660+
if i <= maxCoresE {
661661
eClusterFreqSum += activeFreq
662662
eClusterCount++
663663
} else {

0 commit comments

Comments
 (0)