public void Collect() { using var reader = new StreamReader("/proc/stat"); var stat = ProcStat.FromLine(reader.ReadLine()); if (_lastStat != ProcStat.Empty) { _state.CpuPercent = _lastStat.AverageCpuWith(stat); } _lastStat = stat; }
internal int AverageCpuWith(ProcStat with) => 100 - (int)Math.Floor((Idle - with.Idle) * 100 / (double)(Total - with.Total));