@using ArcaneLibs @using System.Diagnostics

ResourceUsage

Memory usage: @lastMemoryUsage
Time jitter: @lastCpuJitter
@code { private Dictionary MemoryUsage = new(); private Dictionary CpuUsage = new(); private string lastMemoryUsage = ""; private string lastCpuJitter = ""; protected override async Task OnInitializedAsync() { Task.Run(async () => { try { while (true) { lastMemoryUsage = Util.BytesToString((long)(MemoryUsage[DateTime.Now] = GC.GetTotalMemory(false))); if (MemoryUsage.Count > 60) MemoryUsage.Remove(MemoryUsage.Keys.First()); await Task.Delay(1000); } } catch (Exception e) { Console.WriteLine(e); } }); // calculate cpu usage estimate without Process or PerformanceCounter Task.Run(async () => { try { var sw = new Stopwatch(); while (true) { sw.Restart(); await Task.Delay(1000); sw.Stop(); // CpuUsage[DateTime.Now] = sw.ElapsedTicks - TimeSpan.TicksPerSecond; var usage = sw.Elapsed - TimeSpan.FromSeconds(1); CpuUsage[DateTime.Now] = usage.Ticks - TimeSpan.TicksPerSecond; lastCpuJitter = usage.ToString(); if (CpuUsage.Count > 60) CpuUsage.Remove(MemoryUsage.Keys.First()); StateHasChanged(); } } catch (Exception e) { Console.WriteLine(e); } }); await base.OnInitializedAsync(); } }