Skip to content

Commit 4076108

Browse files
committed
apply a8af6b from upstream: improved settings behavior
1 parent de7011b commit 4076108

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

speedtest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class Speedtest {
8282
* @param value - new value for the parameter
8383
*/
8484
setParameter(parameter, value) {
85-
if (this._state !== 0)
86-
throw new Error("You cannot change the test settings after adding server or starting the test");
85+
if (this._state === 3)
86+
throw new Error("You cannot change the test settings while running the test");
8787
this._settings[parameter] = value;
8888
if (parameter === "telemetry_extra") {
8989
this._originalExtra = this._settings.telemetry_extra;

speedtest_worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ function dlTest(done) {
399399
const speed = totLoaded / (t / 1000.0);
400400
if (settings.time_auto) {
401401
// decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here
402-
const bonus = 6.4 * speed / 100000;
403-
bonusT += bonus > 800 ? 800 : bonus;
402+
const bonus = 5.0 * speed / 100000;
403+
bonusT += bonus > 400 ? 400 : bonus;
404404
}
405405
// update status
406406
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) {
557557
const speed = totLoaded / (t / 1000.0);
558558
if (settings.time_auto) {
559559
// decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here
560-
const bonus = 6.4 * speed / 100000;
561-
bonusT += bonus > 800 ? 800 : bonus;
560+
const bonus = 5.0 * speed / 100000;
561+
bonusT += bonus > 400 ? 400 : bonus;
562562
}
563563
// update status
564564
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

0 commit comments

Comments
 (0)