mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added efficiency and performance cores to the dashboard
This commit is contained in:
@@ -601,6 +601,41 @@ public func getIOProperties(_ entry: io_registry_entry_t) -> NSDictionary? {
|
||||
return properties?.takeUnretainedValue()
|
||||
}
|
||||
|
||||
public func getIOName(_ entry: io_registry_entry_t) -> String? {
|
||||
let pointer = UnsafeMutablePointer<io_name_t>.allocate(capacity: 1)
|
||||
|
||||
let result = IORegistryEntryGetName(entry, pointer)
|
||||
if result != kIOReturnSuccess {
|
||||
print("Error IORegistryEntryGetName(): " + (String(cString: mach_error_string(result), encoding: String.Encoding.ascii) ?? "unknown error"))
|
||||
return nil
|
||||
}
|
||||
|
||||
return String(cString: UnsafeRawPointer(pointer).assumingMemoryBound(to: CChar.self))
|
||||
}
|
||||
|
||||
public func getIOChildrens(_ entry: io_registry_entry_t) -> [String]? {
|
||||
var iter: io_iterator_t = io_iterator_t()
|
||||
if IORegistryEntryGetChildIterator(entry, kIOServicePlane, &iter) != kIOReturnSuccess {
|
||||
return nil
|
||||
}
|
||||
|
||||
var iterator: io_registry_entry_t = 1
|
||||
var list: [String] = []
|
||||
while iterator != 0 {
|
||||
iterator = IOIteratorNext(iter)
|
||||
|
||||
let pointer = UnsafeMutablePointer<io_name_t>.allocate(capacity: 1)
|
||||
if IORegistryEntryGetName(iterator, pointer) != kIOReturnSuccess {
|
||||
continue
|
||||
}
|
||||
|
||||
list.append(String(cString: UnsafeRawPointer(pointer).assumingMemoryBound(to: CChar.self)))
|
||||
IOObjectRelease(iterator)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
public class ColorView: NSView {
|
||||
public var inactiveColor: NSColor = NSColor.lightGray.withAlphaComponent(0.75)
|
||||
|
||||
|
||||
@@ -191,6 +191,24 @@ class Dashboard: NSScrollView {
|
||||
}
|
||||
value += "\(mini)"
|
||||
}
|
||||
|
||||
if cpu.eCores != nil || cpu.pCores != nil {
|
||||
if !value.isEmpty {
|
||||
value += "\n"
|
||||
}
|
||||
|
||||
var mini = ""
|
||||
if let eCores = cpu.eCores {
|
||||
mini += localizedString("Number of e-cores", "\(eCores)")
|
||||
}
|
||||
if let pCores = cpu.pCores {
|
||||
if mini != "" {
|
||||
mini += ", "
|
||||
}
|
||||
mini += localizedString("Number of p-cores", "\(pCores)")
|
||||
}
|
||||
value += "\(mini)"
|
||||
}
|
||||
} else {
|
||||
value = localizedString("Unknown")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user