From d856fd0752679df8d30cd952199edb799cbfe113 Mon Sep 17 00:00:00 2001 From: Piers O'Hanlon Date: Wed, 3 Jun 2020 17:36:13 +0100 Subject: [PATCH] Reversed order of samplesize test to match usage by getAverageSlidingWindow() --- src/streaming/rules/ThroughputHistory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/streaming/rules/ThroughputHistory.js b/src/streaming/rules/ThroughputHistory.js index d9c0a8f04c..8dcc391284 100644 --- a/src/streaming/rules/ThroughputHistory.js +++ b/src/streaming/rules/ThroughputHistory.js @@ -159,7 +159,7 @@ function ThroughputHistory(config) { } else if (isThroughput) { // if throughput samples vary a lot, average over a wider sample for (let i = 1; i < sampleSize; ++i) { - const ratio = arr[i] / arr[i - 1]; + const ratio = arr[arr.length - i] / arr[arr.length - i - 1]; if (ratio >= THROUGHPUT_INCREASE_SCALE || ratio <= 1 / THROUGHPUT_DECREASE_SCALE) { sampleSize += 1; if (sampleSize === arr.length) { // cannot increase sampleSize beyond arr.length