mirror of
https://github.com/Phantop/LADXHD.git
synced 2024-10-31 20:04:18 +00:00
29 lines
622 B
C#
29 lines
622 B
C#
|
using System.Linq;
|
|||
|
|
|||
|
namespace ProjectZ.Base
|
|||
|
{
|
|||
|
public class TickCounter
|
|||
|
{
|
|||
|
public int AverageTime;
|
|||
|
|
|||
|
private readonly int[] _timeCounts;
|
|||
|
private int _currentIndex;
|
|||
|
|
|||
|
public TickCounter(int average)
|
|||
|
{
|
|||
|
_timeCounts = new int[average];
|
|||
|
}
|
|||
|
|
|||
|
public void AddTick(long tick)
|
|||
|
{
|
|||
|
_timeCounts[_currentIndex] = (int)tick;
|
|||
|
|
|||
|
_currentIndex++;
|
|||
|
if (_currentIndex >= _timeCounts.Length)
|
|||
|
_currentIndex = 0;
|
|||
|
|
|||
|
AverageTime = (int)_timeCounts.Average();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|