mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
feat: moved from JSON objects of metrics to simplified strings for the Stats Remote
This commit is contained in:
@@ -52,9 +52,17 @@ public struct GPU_Info: Codable {
|
||||
self.renderUtilization = render
|
||||
self.tilerUtilization = tiler
|
||||
}
|
||||
|
||||
public func remote() -> String {
|
||||
var id = self.id
|
||||
if self.id.isEmpty {
|
||||
id = "0"
|
||||
}
|
||||
return "\(id),1,\(self.utilization ?? 0),\(self.renderUtilization ?? 0),\(self.tilerUtilization ?? 0),,"
|
||||
}
|
||||
}
|
||||
|
||||
public class GPUs: Codable {
|
||||
public class GPUs: Codable, RemoteType {
|
||||
private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.GPU.SynchronizedArray")
|
||||
|
||||
private var _list: [GPU_Info] = []
|
||||
@@ -82,6 +90,18 @@ public class GPUs: Codable {
|
||||
internal func active() -> [GPU_Info] {
|
||||
return self.list.filter{ $0.state && $0.utilization != nil }.sorted{ $0.utilization ?? 0 > $1.utilization ?? 0 }
|
||||
}
|
||||
|
||||
public func remote() -> Data? {
|
||||
var string = "\(self.list.count),"
|
||||
for (i, v) in self.list.enumerated() {
|
||||
string += v.remote()
|
||||
if i != self.list.count {
|
||||
string += ","
|
||||
}
|
||||
}
|
||||
string += "$"
|
||||
return string.data(using: .utf8)
|
||||
}
|
||||
}
|
||||
|
||||
public class GPU: Module {
|
||||
|
||||
Reference in New Issue
Block a user