public void Grow_Usage() { if (CrossInfo.ThePlatform == CrossInfo.Platform.Windows) { return; } CpuLoader.Run(1, 1, true); CpuUsageScope scope = CrossInfo.ThePlatform == CrossInfo.Platform.MacOSX ? CpuUsageScope.Process : CpuUsageScope.Thread; Console.WriteLine($"Supported scope: {scope}"); LinuxResourceUsageReader.GetByScope(scope); var prev = LinuxResourceUsageReader.GetByScope(scope); for (int i = 0; i < 10; i++) { CpuLoader.Run(1, 1, true); CpuUsage?next = LinuxResourceUsageReader.GetByScope(scope); Console.WriteLine($" {i} -> {next}"); Assert.GreaterOrEqual(next.Value.KernelUsage.TotalMicroSeconds, prev.Value.KernelUsage.TotalMicroSeconds); Assert.GreaterOrEqual(next.Value.UserUsage.TotalMicroSeconds, prev.Value.UserUsage.TotalMicroSeconds); prev = next; } }
public void Get_Thread_Usage() { if (CrossInfo.ThePlatform == CrossInfo.Platform.Windows) { Console.WriteLine($"LinuxResourceUsageReader is not supported on platform {CrossInfo.ThePlatform}"); return; } var usage = LinuxResourceUsageReader.GetByThread(); Console.WriteLine($"LinuxResourceUsageReader.GetByThread(): {usage}"); }