From 95f941149fa1d4903c55eef73ebbc11f8055da52 Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Mon, 17 Aug 2020 22:51:21 +0200 Subject: [PATCH] - fix unnecessary popup interface update (when popup closed) GPU module MVP --- Modules/Battery/popup.swift | 16 ++-- Modules/CPU/popup.swift | 42 ++++----- Modules/Disk/popup.swift | 37 ++++---- Modules/GPU/main.swift | 5 -- Modules/GPU/popup.swift | 147 +++++++++++++++++++++++++++++++- Modules/GPU/reader.swift | 21 +---- Modules/Memory/popup.swift | 33 +++---- Modules/Net/popup.swift | 82 +++++++++--------- Stats.xcodeproj/project.pbxproj | 2 +- 9 files changed, 261 insertions(+), 124 deletions(-) diff --git a/Modules/Battery/popup.swift b/Modules/Battery/popup.swift index fe888f46..6fc76f3c 100644 --- a/Modules/Battery/popup.swift +++ b/Modules/Battery/popup.swift @@ -189,13 +189,15 @@ internal class Popup: NSView { public func processCallback(_ list: [TopProcess]) { DispatchQueue.main.async(execute: { - for i in 0.. { } let utilization = stats["Device Utilization %"] as? Int ?? 0 - let totalVram = accelerator["VRAM,totalMB"] as? Int ?? matchedGPU["VRAM,totalMB"] as? Int ?? 0 - let freeVram = stats["vramFreeBytes"] as? Int ?? 0 - let coreClock = stats["Core Clock(MHz)"] as? Int ?? 0 - var power = stats["Total Power(W)"] as? Int ?? 0 +// let totalVram = (accelerator["VRAM,totalMB"] as? Int ?? matchedGPU["VRAM,totalMB"] as? Int ?? 0) * 1000000 +// let freeVram = stats["vramFreeBytes"] as? Int ?? 0 +// let coreClock = stats["Core Clock(MHz)"] as? Int ?? 0 var temperature = stats["Temperature(C)"] as? Int ?? 0 if IOClass == "IntelAccelerator" { @@ -80,25 +79,11 @@ internal class InfoReader: Reader { temperature = Int(tmp) } } - - if power == 0 { - if let pwr = self.smc?.pointee.getValue("PCPG") { - power = Int(pwr) - } else if let pwr = self.smc?.pointee.getValue("PCGC") { - power = Int(pwr) - } else if let pwr = self.smc?.pointee.getValue("PCGM") { - power = Int(pwr) - } - } } self.gpus.list[idx].state = agcInfo["poweredOffByAGC"] == 0 self.gpus.list[idx].utilization = utilization == 0 ? 0 : Double(utilization)/100 - self.gpus.list[idx].totalVram = totalVram - self.gpus.list[idx].freeVram = freeVram - self.gpus.list[idx].coreClock = coreClock - self.gpus.list[idx].power = power self.gpus.list[idx].temperature = temperature } diff --git a/Modules/Memory/popup.swift b/Modules/Memory/popup.swift index 63666cc5..1ee80c64 100644 --- a/Modules/Memory/popup.swift +++ b/Modules/Memory/popup.swift @@ -161,29 +161,32 @@ internal class Popup: NSView { self.totalField?.stringValue = Units(bytes: Int64(value.total)).getReadableMemory() self.usedField?.stringValue = Units(bytes: Int64(value.used)).getReadableMemory() self.freeField?.stringValue = Units(bytes: Int64(value.free)).getReadableMemory() + + self.circle?.setValue(value.usage) + self.circle?.setSegments([ + circle_segment(value: value.active/value.total, color: NSColor.systemBlue), + circle_segment(value: value.wired/value.total, color: NSColor.systemOrange), + circle_segment(value: value.compressed/value.total, color: NSColor.systemPink) + ]) + self.level?.setLevel(value.pressureLevel) + self.initialized = true } - - self.circle?.setValue(value.usage) - self.circle?.setSegments([ - circle_segment(value: value.active/value.total, color: NSColor.systemBlue), - circle_segment(value: value.wired/value.total, color: NSColor.systemOrange), - circle_segment(value: value.compressed/value.total, color: NSColor.systemPink) - ]) self.chart?.addValue(value.usage) - self.level?.setLevel(value.pressureLevel) }) } public func processCallback(_ list: [TopProcess]) { DispatchQueue.main.async(execute: { - for i in 0..