From a28b83cc1a2efcb05e2a31b9d91103e4d1174387 Mon Sep 17 00:00:00 2001 From: piersoh <42040737+piersoh@users.noreply.github.com> Date: Thu, 4 Jun 2020 07:48:57 +0100 Subject: [PATCH] Reversed order of samplesize test to match usage by getAverageSlidingWindow() (#3276) --- 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