protected virtual void LogUsage(ThreadPoolUsageStats stats) { string message = string.Format("[{0}] IOCP:(Busy={1},Min={2},Max={3}), WORKER:(Busy={4},Min={5},Max={6}), Local CPU: {7}", DateTimeOffset.UtcNow.ToString("u"), stats.BusyIoThreads, stats.MinIoThreads, stats.MaxIoThreads, stats.BusyWorkerThreads, stats.MinWorkerThreads, stats.MaxWorkerThreads, PerfCounterHelper.GetSystemCPU() ); Console.WriteLine(message); }
public static string GetSystemCPU() { string cpu = "unavailable"; float systemCPU; if (PerfCounterHelper.TryGetSystemCPU(out systemCPU)) { cpu = Math.Round(systemCPU, 2) + "%"; } return(cpu); }