perf: merge cpuCoreUsage/cpuCoreFreq/cpuCoreHistory into single cpuCores array
This commit is contained in:
parent
8fdd9692e6
commit
c8d71bd871
3 changed files with 25 additions and 34 deletions
|
|
@ -10,9 +10,7 @@ QtObject {
|
|||
// ── CPU ──────────────────────────────────────────────────────────────
|
||||
property int cpuUsage: 0
|
||||
property real cpuFreqGhz: 0
|
||||
property var cpuCoreUsage: []
|
||||
property var cpuCoreFreq: []
|
||||
property var cpuCoreHistory: []
|
||||
property var cpuCores: [] // [{usage, freq_ghz, history:[]}]
|
||||
property var cpuCoreMaxFreq: []
|
||||
property var cpuCoreTypes: []
|
||||
|
||||
|
|
@ -40,17 +38,17 @@ QtObject {
|
|||
if (ev.type === "cpu") {
|
||||
root.cpuUsage = ev.usage;
|
||||
root.cpuFreqGhz = ev.freq_ghz;
|
||||
root.cpuCoreUsage = ev.core_usage;
|
||||
root.cpuCoreFreq = ev.core_freq_ghz;
|
||||
const histLen = 16;
|
||||
const oldH = root.cpuCoreHistory;
|
||||
const newH = [];
|
||||
for (let i = 0; i < ev.core_usage.length; i++) {
|
||||
const prev = i < oldH.length ? oldH[i] : [];
|
||||
const next = prev.concat([ev.core_usage[i]]);
|
||||
newH.push(next.length > histLen ? next.slice(next.length - histLen) : next);
|
||||
}
|
||||
root.cpuCoreHistory = newH;
|
||||
const prev = root.cpuCores;
|
||||
root.cpuCores = ev.cores.map((c, i) => {
|
||||
const oldHist = prev[i]?.history ?? [];
|
||||
const hist = oldHist.concat([c.usage]);
|
||||
return {
|
||||
usage: c.usage,
|
||||
freq_ghz: c.freq_ghz,
|
||||
history: hist.length > histLen ? hist.slice(hist.length - histLen) : hist
|
||||
};
|
||||
});
|
||||
} else if (ev.type === "mem") {
|
||||
root.memPercent = ev.percent;
|
||||
root.memUsedGb = ev.used_gb;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue