diff options
Diffstat (limited to 'desktop/modules/perf/Perf.js')
| -rw-r--r-- | desktop/modules/perf/Perf.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/desktop/modules/perf/Perf.js b/desktop/modules/perf/Perf.js index eb0dbd7..b94e5b6 100644 --- a/desktop/modules/perf/Perf.js +++ b/desktop/modules/perf/Perf.js @@ -44,6 +44,24 @@ function load(prev, cur) { return Math.max(0, Math.min(100, 100 * (1 - (cur.idle - prev.idle) / dt))); } +// gpu.sh's line as numbers: [vram, rcs busy, rcs clock, ccs busy, ccs clock], +// null when it printed nothing. +function gpuSample(text) { + const n = text.trim().split(/\s+/).map(Number); + return n.length === 5 && n.every(Number.isFinite) ? n : null; +} + +// {render, compute} percent busy between two gpuSample()s, each null when +// its clock did not move. A client exiting mid-sample takes its cycles with +// it, so a dip below zero is clamped. +function gpuLoad(prev, cur) { + const pct = (b, c) => { + if (!prev || !cur || cur[c] <= prev[c]) return null; + return Math.max(0, Math.min(100, 100 * (cur[b] - prev[b]) / (cur[c] - prev[c]))); + }; + return { render: pct(1, 2), compute: pct(3, 4) }; +} + // {total, used} in bytes; used is MemTotal - MemAvailable. function meminfo(text) { const kb = key => { |
