| | 1 | | namespace DCL.FPSDisplay |
| | 2 | | { |
| | 3 | | public class LinealBufferHiccupCounter |
| | 4 | | { |
| 4 | 5 | | private readonly LinealBufferFPSCounter counter = new LinealBufferFPSCounter(); |
| | 6 | | private int hiccupsCountInBuffer = 0; |
| | 7 | | private float hiccupsSum = 0.0f; |
| | 8 | | private float bufferCount = 0.0f; |
| | 9 | |
|
| 0 | 10 | | public int HiccupsCountInBuffer { get => hiccupsCountInBuffer; private set => hiccupsCountInBuffer = value; } |
| 0 | 11 | | public float HiccupsSum { get => hiccupsSum; set => hiccupsSum = value; } |
| | 12 | |
|
| 0 | 13 | | public float CurrentFPSCount() { return counter.CurrentFPSCount(); } |
| | 14 | |
|
| 0 | 15 | | public float GetTotalSeconds() { return bufferCount; } |
| | 16 | |
|
| | 17 | | public void AddDeltaTime(float valueInSeconds) |
| | 18 | | { |
| 3701 | 19 | | if (IsHiccup(counter.values[counter.end])) |
| | 20 | | { |
| 1414 | 21 | | hiccupsCountInBuffer -= 1; |
| 1414 | 22 | | hiccupsSum -= counter.values[counter.end]; |
| | 23 | | } |
| | 24 | |
|
| 3701 | 25 | | if (IsHiccup(valueInSeconds)) |
| | 26 | | { |
| 3343 | 27 | | hiccupsCountInBuffer += 1; |
| 3343 | 28 | | hiccupsSum += valueInSeconds; |
| | 29 | | } |
| | 30 | |
|
| 3701 | 31 | | bufferCount -= counter.values[counter.end]; |
| 3701 | 32 | | bufferCount += valueInSeconds; |
| | 33 | |
|
| 3701 | 34 | | counter.AddDeltaTime(valueInSeconds); |
| 3701 | 35 | | } |
| | 36 | |
|
| 0 | 37 | | public int CurrentHiccupCount() { return hiccupsCountInBuffer; } |
| | 38 | |
|
| 0 | 39 | | private bool IsHiccup(float value) { return value > FPSEvaluation.HICCUP_THRESHOLD_IN_SECONDS; } |
| | 40 | |
|
| 0 | 41 | | public float GetHiccupSum() { return hiccupsSum; } |
| | 42 | | } |
| | 43 | | } |