From 4076108bba857533b1d289dc5ffaccbfea3c3eaf Mon Sep 17 00:00:00 2001 From: SCG82 Date: Mon, 8 Feb 2021 07:36:04 -0800 Subject: [PATCH] apply a8af6b from upstream: improved settings behavior --- speedtest.js | 4 ++-- speedtest_worker.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/speedtest.js b/speedtest.js index 00cd65467..e02a19d5c 100644 --- a/speedtest.js +++ b/speedtest.js @@ -82,8 +82,8 @@ class Speedtest { * @param value - new value for the parameter */ setParameter(parameter, value) { - if (this._state !== 0) - throw new Error("You cannot change the test settings after adding server or starting the test"); + if (this._state === 3) + throw new Error("You cannot change the test settings while running the test"); this._settings[parameter] = value; if (parameter === "telemetry_extra") { this._originalExtra = this._settings.telemetry_extra; diff --git a/speedtest_worker.js b/speedtest_worker.js index 8c2fb1671..b16b41806 100644 --- a/speedtest_worker.js +++ b/speedtest_worker.js @@ -399,8 +399,8 @@ function dlTest(done) { const speed = totLoaded / (t / 1000.0); if (settings.time_auto) { // decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here - const bonus = 6.4 * speed / 100000; - bonusT += bonus > 800 ? 800 : bonus; + const bonus = 5.0 * speed / 100000; + bonusT += bonus > 400 ? 400 : bonus; } // update status dlStatus = Number((speed * 8 * settings.overheadCompensationFactor / (settings.useMebibits ? 1048576 : 1000000)).toFixed(2)); // speed is multiplied by 8 to go from bytes to bits, overhead compensation is applied, then everything is divided by 1048576 or 1000000 to go to megabits/mebibits @@ -557,8 +557,8 @@ function ulTest(done) { const speed = totLoaded / (t / 1000.0); if (settings.time_auto) { // decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here - const bonus = 6.4 * speed / 100000; - bonusT += bonus > 800 ? 800 : bonus; + const bonus = 5.0 * speed / 100000; + bonusT += bonus > 400 ? 400 : bonus; } // update status ulStatus = Number((speed * 8 * settings.overheadCompensationFactor / (settings.useMebibits ? 1048576 : 1000000)).toFixed(2)); // speed is multiplied by 8 to go from bytes to bits, overhead compensation is applied, then everything is divided by 1048576 or 1000000 to go to megabits/mebibits