public void Stop() { var process = Process.GetCurrentProcess(); var survivedMemorySizeAfter = AppDomain.CurrentDomain.MonitoringSurvivedMemorySize; var totalAllocatedMemorySizeAfter = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize; var totalProcessorTimeAfter = AppDomain.CurrentDomain.MonitoringTotalProcessorTime.Ticks; var survivedMemorySizeDifference = new Difference(this.survivedMemorySizeBefore, survivedMemorySizeAfter); var totalAllocatedMemorySizeDifference = new Difference(this.totalAllocatedMemorySizeBefore, totalAllocatedMemorySizeAfter); var totalProcessorTimeDifference = new Difference(this.totalProcessorTimeBefore, totalProcessorTimeAfter); survivedMemorySizeDifference.Write("SurvivedMemorySize"); totalAllocatedMemorySizeDifference.Write("TotalAllocatedMemorySize"); totalProcessorTimeDifference.Write("TotalProcessorTime"); foreach (var kv in this.performanceCounters) { var performanceCounter = kv.Key; var beforeValue = kv.Value.RawValue; var afterValue = performanceCounter.NextSample().RawValue; var difference = new Difference(beforeValue, afterValue); difference.Write(performanceCounter.CounterName); } foreach (var property in this.meterProperties) { var beforeValue = this.before[property.Name]; var value = property.GetValue(process, null); long afterValue; if (value is int) { afterValue = (int)value; } else { afterValue = (long)value; } var difference = new Difference(beforeValue, afterValue); difference.Write(property.Name); } }