Skip to content

Commit

Permalink
apply a8af6b from upstream: improved settings behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
SCG82 committed Feb 8, 2021
1 parent de7011b commit 4076108
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions speedtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions speedtest_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4076108

Please sign in to comment.