Process.Linux/OSX: avoid loading full ProcessInfo for ProcessName and ToString.#126449
Process.Linux/OSX: avoid loading full ProcessInfo for ProcessName and ToString.#126449tmds wants to merge 2 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
|
Do you have any AOT binary size numbers for how much this saves (e.g. for an all that does just |
using System.Diagnostics;
var process = Process.GetCurrentProcess();
var sw = Stopwatch.StartNew();
long iterations = 0;
while (sw.ElapsedMilliseconds < 5000)
{
_ = process.ProcessName;
process.Refresh();
iterations++;
}
sw.Stop();
Console.WriteLine($"Iterations: {iterations}");
Console.WriteLine($"Elapsed: {sw.Elapsed}");
Console.WriteLine($"Per call: {sw.Elapsed.TotalNanoseconds / iterations:F1} ns");Results on Linux: That is about a 7x speedup.
On Linux, it trims out about 4.5KB by eliminating the |
I'll do an exact measurement. The speed-up turned out to be the actual improvement. |
|
|
This speeds up ProcessName/ToString.
It also enables trimming out ProcessInfo support when no APIs that require ProcessInfo are used.