diff --git a/ATxDiagnostics/ATxDiagnostics.cs b/ATxDiagnostics/ATxDiagnostics.cs index a03d5af2c92b494d1f6340582c305fc166c425ca..90c72315d7fac10ce883ff333b502b55fe8f3b98 100644 --- a/ATxDiagnostics/ATxDiagnostics.cs +++ b/ATxDiagnostics/ATxDiagnostics.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Management; using ATxCommon; using NLog; @@ -24,6 +25,7 @@ namespace ATxDiagnostics LogManager.Configuration = logConfig; Log.Debug(Conv.BytesToString(SystemChecks.GetFreeDriveSpace("C:"))); + GetCpuCounter(); /* Log.Debug(SystemChecks.GetCpuUsage()); Log.Debug(SystemChecks.GetCpuUsage()); @@ -74,5 +76,19 @@ namespace ATxDiagnostics return usageInt32; } + + private static void GetCpuCounter() { + var counter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); + var i = 0; + while (true) { + i++; + //Log.Debug("PerformanceCounter reading {1}: {0}", counter.NextValue(), i); + var watch = Stopwatch.StartNew(); + var reading = counter.NextValue(); + watch.Stop(); + Console.WriteLine("reading {1} (took {2} ms): {0}", reading, i, watch.ElapsedMilliseconds); + System.Threading.Thread.Sleep(250); + } + } } }