Fix thread F3 avg time >0 when runtime ratio is 1

This commit is contained in:
James Seibel
2024-12-12 07:19:44 -06:00
parent 3c5225534f
commit 1f0290c37b
@@ -84,12 +84,13 @@ public class RateLimitedThreadPoolExecutor extends ThreadPoolExecutor
{
super.beforeExecute(thread, runnable);
long deltaMs = TimeUnit.NANOSECONDS.toMillis(this.lastRunDurationNanoTimeRef.get());
this.runTimeInMsRollingAverage.addValue(deltaMs);
if (this.runTimeRatio < 1.0 && this.lastRunDurationNanoTimeRef.get() != -1)
{
try
{
long deltaMs = TimeUnit.NANOSECONDS.toMillis(this.lastRunDurationNanoTimeRef.get());
this.runTimeInMsRollingAverage.addValue(deltaMs);
Thread.sleep((long) (deltaMs / this.runTimeRatio - deltaMs));
}
catch (InterruptedException ignored) { }