mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed crashes on some M2 macs caused by frequency reader (#2317)
This commit is contained in:
@@ -70,7 +70,7 @@ internal class LoadReader: Reader<CPU_Load> {
|
||||
}
|
||||
self.CPUUsageLock.unlock()
|
||||
|
||||
let showHyperthratedCores = Store.shared.bool(key: "CPU_hyperhreading", defaultValue: false)
|
||||
let showHyperthratedCores = Store.shared.bool(key: "CPU_hyperhreading", defaultValue: false)
|
||||
if showHyperthratedCores || !self.hasHyperthreadingCores {
|
||||
self.response.usagePerCore = self.usagePerCore
|
||||
} else {
|
||||
@@ -355,13 +355,15 @@ public class FrequencyReader: Reader<[Double]> {
|
||||
|
||||
private func calculateFrequencies(dict: CFDictionary, freqs: [Int32]) -> Double {
|
||||
let items = self.getResidencies(dict: dict)
|
||||
let offset = items.firstIndex { $0.0 != "IDLE" && $0.0 != "DOWN" && $0.0 != "OFF" }!
|
||||
guard let offset = items.firstIndex(where: { $0.0 != "IDLE" && $0.0 != "DOWN" && $0.0 != "OFF" }) else { return 0 }
|
||||
let usage = items.dropFirst(offset).reduce(0.0) { $0 + Double($1.f) }
|
||||
let count = freqs.count
|
||||
var avgFreq: Double = 0
|
||||
|
||||
for i in 0..<count {
|
||||
let percent = usage == 0 ? 0 : Double(items[i + offset].f) / usage
|
||||
let key = i + offset
|
||||
if !items.indices.contains(key) { continue }
|
||||
let percent = usage == 0 ? 0 : Double(items[key].f) / usage
|
||||
avgFreq += percent * Double(freqs[i])
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>657</string>
|
||||
<string>659</string>
|
||||
<key>Description</key>
|
||||
<string>Simple macOS system monitor in your menu bar</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.11.24</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>657</string>
|
||||
<string>659</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
|
||||
Reference in New Issue
Block a user