Skip to content

Commit

Permalink
chore: Rename variable for code coherence
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
  • Loading branch information
maximilien-noal committed Nov 9, 2024
1 parent 0a83dd9 commit a01929d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Spice86.Shared/Diagnostics/PerformanceMeasurer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PerformanceMeasurer : IPerformanceMeasurer {
/// </summary>
public PerformanceMeasurer() => _lastTimeInMilliseconds = GetCurrentTime();

private long _firstMeasureTimeInTicks = 0;
private long _firstMeasureTimeInMilliseconds = 0;

private const int WindowSizeInSeconds = 30;

Expand All @@ -32,7 +32,7 @@ public class PerformanceMeasurer : IPerformanceMeasurer {
public void UpdateValue(long newMeasure) {
long newTimeInMilliseconds = GetCurrentTime();
if (IsFirstMeasurement()) {
_firstMeasureTimeInTicks = newTimeInMilliseconds;
_firstMeasureTimeInMilliseconds = newTimeInMilliseconds;
} else if (IsLastMeasurementExpired(newTimeInMilliseconds)) {
ResetMetrics(newTimeInMilliseconds);
}
Expand All @@ -49,17 +49,17 @@ public void UpdateValue(long newMeasure) {
}

private bool IsFirstMeasurement() {
return _firstMeasureTimeInTicks == 0;
return _firstMeasureTimeInMilliseconds == 0;
}

private void ResetMetrics(long newTimeInMilliseconds) {
_firstMeasureTimeInTicks = newTimeInMilliseconds;
_firstMeasureTimeInMilliseconds = newTimeInMilliseconds;
_sampledMetricsCount = 0;
AverageValuePerSecond = 0;
}

private bool IsLastMeasurementExpired(long newTimeInMilliseconds) {
return (TimeSpan.FromTicks(newTimeInMilliseconds) - TimeSpan.FromTicks(_firstMeasureTimeInTicks)).TotalSeconds >= WindowSizeInSeconds;
return (TimeSpan.FromTicks(newTimeInMilliseconds) - TimeSpan.FromTicks(_firstMeasureTimeInMilliseconds)).TotalSeconds >= WindowSizeInSeconds;
}

private static long ApproxRollingAverage(long measureAverage, long valuePerSecond, long sampledMetricsCount) {
Expand Down

0 comments on commit a01929d

Please sign in to comment.