aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/perf/Perf.js
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/perf/Perf.js')
-rw-r--r--desktop/modules/perf/Perf.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/desktop/modules/perf/Perf.js b/desktop/modules/perf/Perf.js
index b853f50..d84c694 100644
--- a/desktop/modules/perf/Perf.js
+++ b/desktop/modules/perf/Perf.js
@@ -72,6 +72,20 @@ function df(text) {
return out;
}
+// `du -B1 -d1 <dir>`: {total, items} with items largest first by basename,
+// or null when du printed nothing. du prints the directory itself last, and
+// it is also the largest line, so the total is the maximum.
+function du(text) {
+ const rows = [];
+ for (const line of text.split("\n")) {
+ const m = /^(\d+)\t(.*)$/.exec(line);
+ if (m) rows.push({ name: m[2].replace(/.*\//, ""), bytes: Number(m[1]) });
+ }
+ if (!rows.length) return null;
+ rows.sort((x, y) => y.bytes - x.bytes);
+ return { total: rows[0].bytes, items: rows.slice(1) };
+}
+
// VRAM in bytes from the fdinfo scan: drm-resident-vram0 of every xe fd,
// counted once per drm-client-id because a client holds several fds.
function vram(text) {