ace/Source/ACE.Common/Performance/RateMonitor.cs
Mag-nus 2b61b28147
Cumulative updates (#4180)
* Many lb group performance related updates

* fixes

* tweak partitioner

* Implement LandblockGroupMinSpacingWhenDormant

* More threaddebug

* cleanup
2024-06-28 10:43:53 -04:00

68 lines
1.6 KiB
C#

using System.Diagnostics;
namespace ACE.Common.Performance
{
public class RateMonitor
{
private readonly Stopwatch stopwatch = new Stopwatch();
public readonly TimedEventHistory EventHistory = new TimedEventHistory();
/// <summary>
/// Stops time interval measurement and resets the elapsed time to zero.
/// </summary>
public void Reset()
{
stopwatch.Reset();
}
/// <summary>
/// Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
/// </summary>
public void Restart()
{
stopwatch.Restart();
}
/// <summary>
/// Stops time interval measurement.
/// </summary>
public void Pause()
{
stopwatch.Stop();
}
/// <summary>
/// Starts time interval measurement.
/// </summary>
public void Resume()
{
stopwatch.Start();
}
/// <summary>
/// Stops time interval measurement.
/// </summary>
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();
}
}
}