diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-27 13:56:24 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-27 13:56:24 +0100 |
| commit | 8c15dc1205d879591318cf365e15b014477329c1 (patch) | |
| tree | f315c92394f8db96c36f56c8a93f9d8feedade20 /desktop/modules/perf/test_perf.js | |
| parent | 6b68cae8e0c4ec43c4a9a8a812a644b7bea746e7 (diff) | |
| download | quickshell-8c15dc1205d879591318cf365e15b014477329c1.tar.gz quickshell-8c15dc1205d879591318cf365e15b014477329c1.zip | |
network: traffic, its busiest processes and the IPs on the page
The rx/tx graph, the LAN address and the public IP with its pin move from
the perf page's NET card to the network page, where they belong; the NET
card is gone. Perf still samples and owns all of them: the graph opens on
the last minute of history, and a public IP that differs from the pin
still lights the perf tile's dot.
Below the graph, the five busiest processes. nethogs is installed but
cannot open any interface unprivileged, so the rates come from
`ss -tinpH`: per-socket byte counters diffed every 2s while the page is
open, summed by process name. That counts TCP only, and only the user's
own processes, so QUIC and system services are missing. The list is held
at five rows tall so the IP lines under it never move.
Perf.js gains sockets() and netProcs(), with tests in test_perf.js.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/perf/test_perf.js')
| -rw-r--r-- | desktop/modules/perf/test_perf.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/desktop/modules/perf/test_perf.js b/desktop/modules/perf/test_perf.js index f2caa94..b7d9dbb 100644 --- a/desktop/modules/perf/test_perf.js +++ b/desktop/modules/perf/test_perf.js @@ -20,7 +20,7 @@ const src = fs.readFileSync(__dirname + "/Perf.js", "utf8") .replace(/^\.pragma library$/m, ""); const P = new Function(src + "\nreturn { cpuTimes, load, meminfo, df, vram, rate, " + "hwmonMap, lanAddr, cpuModel, du, band, worst, isIPv4, parsePubip, formatPubip, " + - "ipCheck, due, push, bytes, speed, procs };")(); + "ipCheck, due, push, bytes, speed, procs, sockets, netProcs };")(); // cpuTimes: aggregate first, then cores; idle is idle + iowait. const stat = [ @@ -171,4 +171,30 @@ assert.deepStrictEqual(P.procs(frame), [ ]); assert.deepStrictEqual(P.procs(""), []); +// sockets: owned sockets with their -i counters; ownerless ones skipped. +const ss = [ + "ESTAB 0 0 10.0.0.5:35806 192.0.2.1:443 users:((\"firefox\",pid=12,fd=53))", + "\t cubic rto:340 bytes_sent:100 bytes_acked:101 bytes_received:5000 segs_out:2", + "ESTAB 0 0 10.0.0.5:22 192.0.2.9:5000", + "\t cubic bytes_sent:999 bytes_received:999", + "SYN-SENT 0 1 10.0.0.5:49916 192.0.2.2:65081 users:((\"ktorrent\",pid=7,fd=67))", + "\t cubic rto:1000 segs_out:3", +].join("\n"); +const socks = P.sockets(ss); +assert.deepStrictEqual(socks, [ + { key: "10.0.0.5:35806 192.0.2.1:443 12", name: "firefox", rx: 5000, tx: 100 }, + { key: "10.0.0.5:49916 192.0.2.2:65081 7", name: "ktorrent", rx: 0, tx: 0 }, +]); + +// netProcs: deltas over the interval summed by name; a new socket counts +// from zero, idle processes drop out. +const later = [ + { key: "a", name: "firefox", rx: 5000 + 4000, tx: 100 }, + { key: "b", name: "firefox", rx: 2000, tx: 0 }, + { key: "c", name: "ktorrent", rx: 0, tx: 0 }, +]; +assert.deepStrictEqual(P.netProcs([{ key: "a", name: "firefox", rx: 5000, tx: 100 }], later, 2), + [{ name: "firefox", rx: 3000, tx: 0 }]); +assert.deepStrictEqual(P.netProcs([], later, 0), []); + console.log("test_perf: ok"); |
