From 0743593285bd87cd2c7fb8bfb88c981c2d5092e2 Mon Sep 17 00:00:00 2001 From: Dan Barbulescu <danbarbulescu.main@gmail.com> Date: Mon, 17 Dec 2018 12:02:27 +0100 Subject: [PATCH] lowered timeouts for network test; changed upload test character set to base64 characters, randomly chosen; --- src/app/sys-check/backend.service.ts | 9 ++++++++- .../sys-check/network-check/network-check.component.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/sys-check/backend.service.ts b/src/app/sys-check/backend.service.ts index 9cefc5b1..d607a4de 100644 --- a/src/app/sys-check/backend.service.ts +++ b/src/app/sys-check/backend.service.ts @@ -131,6 +131,8 @@ export class BackendService { // uses https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout // and https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send + const base64Characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz0123456789+/'; + let startingTime; const xhr = new XMLHttpRequest(); xhr.open('POST', this.serverUrl + 'doSysCheckUploadTest.php', true); @@ -167,7 +169,12 @@ export class BackendService { let uploadedContent = ''; for (let i = 1; i <= requestedUploadSize; i++) { - uploadedContent += String(Math.floor(Math.random() * 10)); + let randomCharacterID = Math.floor(Math.random() * 63); + if (randomCharacterID > base64Characters.length - 1) { + // failsafe, in case the random number generator is a bit imprecisely programmed and gives too big of a number back + randomCharacterID = base64Characters.length - 1; + } + uploadedContent += base64Characters[randomCharacterID]; } startingTime = new Date().getTime(); xhr.send('package=' + uploadedContent); diff --git a/src/app/sys-check/network-check/network-check.component.ts b/src/app/sys-check/network-check/network-check.component.ts index 7edffe51..e7fac6e1 100644 --- a/src/app/sys-check/network-check/network-check.component.ts +++ b/src/app/sys-check/network-check/network-check.component.ts @@ -95,7 +95,7 @@ export class NetworkCheckComponent implements OnInit { } if (shouldContinue) { - const timeout = currentSizeIteration * 3000; // 3000 (1st iteration), 6000 (2nd iteration), 9000 (3rd iteration) + const timeout = 1000 + (currentSizeIteration - 1) * 2000; // 1000 (1st iteration), 3000 (2nd iteration), 5000 (3rd iteration) if (whatIsBeingTested === 'download') { updateStatus(`Downloadgeschwindigkeit wird getestet... (Testgröße: ${currentSize} bytes; Test: ${currentSizeIteration}/3)`); -- GitLab