Status box: show RemSound's own CPU and memory usage (held for next release)
New last status line "CPU usage 2% and memory 184 MB" — CPU as a share of the whole machine (Task Manager style: process CPU-time delta / wall-clock / logical-core count), memory as the working set via the same MB-to-GB formatter the totals use. Sampled on the existing once-a-second status tick with a cached Process handle. Shows on screen and reads/copies with the rest of the status (Ed's idea). Held for the next release. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
be32a060e7
commit
771a358a87
@@ -188,7 +188,7 @@ The main window has three parts, stacked top to bottom:
|
|||||||
|
|
||||||
1. A **menu bar** at the top with four menus — _File_ , _Record_ , _Options_ and _Help_. See Menus.
|
1. A **menu bar** at the top with four menus — _File_ , _Record_ , _Options_ and _Help_. See Menus.
|
||||||
2. A **row of tabs** with three tabs — Connectivity, Audio inputs and outputs, Audio profile. Each tab has its own Alt+letter shortcuts that only work when that tab is the one showing — so the same letter can do different things on different tabs without clashing.
|
2. A **row of tabs** with three tabs — Connectivity, Audio inputs and outputs, Audio profile. Each tab has its own Alt+letter shortcuts that only work when that tab is the one showing — so the same letter can do different things on different tabs without clashing.
|
||||||
3. A **status line** at the bottom that updates once a second with how long you've been connected, how many peers you have, whether sound is flowing, and connection health.
|
3. A **status line** at the bottom that updates once a second with how long you've been connected, how many peers you have, whether sound is flowing, connection health, and RemSound's own CPU and memory usage.
|
||||||
|
|
||||||
Tab| What it's for
|
Tab| What it's for
|
||||||
---|---
|
---|---
|
||||||
|
|||||||
+1
-1
@@ -219,7 +219,7 @@ ul, ol { padding-left: 1.4em; }
|
|||||||
<ol>
|
<ol>
|
||||||
<li>A <strong>menu bar</strong> at the top with four menus — <em>File</em>, <em>Record</em>, <em>Options</em> and <em>Help</em>. See <a href="#menu-bar">Menus</a>.</li>
|
<li>A <strong>menu bar</strong> at the top with four menus — <em>File</em>, <em>Record</em>, <em>Options</em> and <em>Help</em>. See <a href="#menu-bar">Menus</a>.</li>
|
||||||
<li>A <strong>row of tabs</strong> with three tabs — Connectivity, Audio inputs and outputs, Audio profile. Each tab has its own Alt+letter shortcuts that only work when that tab is the one showing — so the same letter can do different things on different tabs without clashing.</li>
|
<li>A <strong>row of tabs</strong> with three tabs — Connectivity, Audio inputs and outputs, Audio profile. Each tab has its own Alt+letter shortcuts that only work when that tab is the one showing — so the same letter can do different things on different tabs without clashing.</li>
|
||||||
<li>A <strong>status line</strong> at the bottom that updates once a second with how long you've been connected, how many peers you have, whether sound is flowing, and connection health.</li>
|
<li>A <strong>status line</strong> at the bottom that updates once a second with how long you've been connected, how many peers you have, whether sound is flowing, connection health, and RemSound's own CPU and memory usage.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|||||||
@@ -269,6 +269,10 @@ public sealed class MainForm : Form
|
|||||||
private DateTime? statusConnectedSinceUtc;
|
private DateTime? statusConnectedSinceUtc;
|
||||||
// Time of the last "speak status" hotkey press, for double-press-to-copy detection.
|
// Time of the last "speak status" hotkey press, for double-press-to-copy detection.
|
||||||
private DateTime lastSpeakStatusPressUtc = DateTime.MinValue;
|
private DateTime lastSpeakStatusPressUtc = DateTime.MinValue;
|
||||||
|
// Process CPU-time at the last status sample, for the status box's CPU-usage line. Cached Process
|
||||||
|
// handle so the once-a-second status tick doesn't allocate a new one each time.
|
||||||
|
private TimeSpan lastStatusCpuTime;
|
||||||
|
private readonly System.Diagnostics.Process statusSelfProcess = System.Diagnostics.Process.GetCurrentProcess();
|
||||||
// Per-list state (used by sync helpers — was per-method in the old dialog).
|
// Per-list state (used by sync helpers — was per-method in the old dialog).
|
||||||
private bool suppressConnectedCheck;
|
private bool suppressConnectedCheck;
|
||||||
private bool suppressDiscoveredCheck;
|
private bool suppressDiscoveredCheck;
|
||||||
@@ -3397,7 +3401,10 @@ public sealed class MainForm : Form
|
|||||||
var nowUtc = DateTime.UtcNow;
|
var nowUtc = DateTime.UtcNow;
|
||||||
var txBytes = sender.BytesSent;
|
var txBytes = sender.BytesSent;
|
||||||
var rxBytes = receiver.BytesReceived;
|
var rxBytes = receiver.BytesReceived;
|
||||||
double txKbs = 0, rxKbs = 0;
|
statusSelfProcess.Refresh();
|
||||||
|
var cpuTime = statusSelfProcess.TotalProcessorTime;
|
||||||
|
var workingSetBytes = statusSelfProcess.WorkingSet64;
|
||||||
|
double txKbs = 0, rxKbs = 0, cpuPercent = 0;
|
||||||
if (lastStatusSampleUtc != DateTime.MinValue)
|
if (lastStatusSampleUtc != DateTime.MinValue)
|
||||||
{
|
{
|
||||||
var elapsed = (nowUtc - lastStatusSampleUtc).TotalSeconds;
|
var elapsed = (nowUtc - lastStatusSampleUtc).TotalSeconds;
|
||||||
@@ -3405,11 +3412,17 @@ public sealed class MainForm : Form
|
|||||||
{
|
{
|
||||||
txKbs = (txBytes - lastStatusTxBytes) / 1024.0 / elapsed;
|
txKbs = (txBytes - lastStatusTxBytes) / 1024.0 / elapsed;
|
||||||
rxKbs = (rxBytes - lastStatusRxBytes) / 1024.0 / elapsed;
|
rxKbs = (rxBytes - lastStatusRxBytes) / 1024.0 / elapsed;
|
||||||
|
// CPU as a share of the whole machine (the Task Manager number): the process CPU-time
|
||||||
|
// delta over wall-clock, divided by the logical-core count.
|
||||||
|
var cpuDelta = (cpuTime - lastStatusCpuTime).TotalSeconds;
|
||||||
|
cpuPercent = cpuDelta / elapsed / Math.Max(1, Environment.ProcessorCount) * 100.0;
|
||||||
|
if (cpuPercent < 0) cpuPercent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastStatusSampleUtc = nowUtc;
|
lastStatusSampleUtc = nowUtc;
|
||||||
lastStatusTxBytes = txBytes;
|
lastStatusTxBytes = txBytes;
|
||||||
lastStatusRxBytes = rxBytes;
|
lastStatusRxBytes = rxBytes;
|
||||||
|
lastStatusCpuTime = cpuTime;
|
||||||
|
|
||||||
// Healthy peers from heartbeat. Map each to its display label (the user-friendly
|
// Healthy peers from heartbeat. Map each to its display label (the user-friendly
|
||||||
// name from selectedPeerLabels, falling back to the address).
|
// name from selectedPeerLabels, falling back to the address).
|
||||||
@@ -3473,7 +3486,8 @@ public sealed class MainForm : Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine($"Receiving {rxKbs:0.0} kB/s; sending {txKbs:0.0} kB/s.");
|
sb.AppendLine($"Receiving {rxKbs:0.0} kB/s; sending {txKbs:0.0} kB/s.");
|
||||||
sb.Append($"Total received {FormatDataSize(receiver.BytesReceived)}; sent {FormatDataSize(sender.BytesSent)}.");
|
sb.AppendLine($"Total received {FormatDataSize(receiver.BytesReceived)}; sent {FormatDataSize(sender.BytesSent)}.");
|
||||||
|
sb.Append($"CPU usage {cpuPercent:0}% and memory {FormatDataSize(workingSetBytes)}.");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user