using System.Diagnostics; namespace ACE.Common.Performance { public class RateMonitor { private readonly Stopwatch stopwatch = new Stopwatch(); public readonly TimedEventHistory EventHistory = new TimedEventHistory(); /// /// Stops time interval measurement and resets the elapsed time to zero. /// public void Reset() { stopwatch.Reset(); } /// /// Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time. /// public void Restart() { stopwatch.Restart(); } /// /// Stops time interval measurement. /// public void Pause() { stopwatch.Stop(); } /// /// Starts time interval measurement. /// public void Resume() { stopwatch.Start(); } /// /// Stops time interval measurement. /// public void RegisterEventEnd() { stopwatch.Stop(); RegisterEvent(stopwatch.Elapsed.TotalSeconds); } public void RegisterEvent(double totalSeconds) { EventHistory.RegisterEvent(totalSeconds); } public void ClearEventHistory() { EventHistory.ClearHistory(); } public override string ToString() { return EventHistory.ToString(); } } }