Minor improvement to previous commit

This commit is contained in:
dosse91 2017-03-03 14:20:27 +01:00
parent c045707e09
commit cf24c81f3e
3 changed files with 7 additions and 7 deletions

BIN
doc.pdf

Binary file not shown.

View file

@ -1,5 +1,5 @@
/* /*
HTML5 Speedtest v4.0 HTML5 Speedtest v4.1
by Federico Dossena by Federico Dossena
https://github.com/adolfintel/speedtest/ https://github.com/adolfintel/speedtest/
GNU LGPLv3 License GNU LGPLv3 License
@ -144,9 +144,9 @@ function dlTest(done){
startT=new Date().getTime(), //timestamp when test was started startT=new Date().getTime(), //timestamp when test was started
failed=false; //set to true if a stream fails failed=false; //set to true if a stream fails
xhr=[]; xhr=[];
//function to create a download stream //function to create a download stream. streams are slightly delayed so that they will not end at the same time
var testStream=function(i,delay){ var testStream=function(i,delay){
setTimeout(function(){ //delay creation of a stream slightly so that the new stream is completely detached from the one that created it setTimeout(function(){
if(testStatus!=1) return; //delayed stream ended up starting after the end of the download test if(testStatus!=1) return; //delayed stream ended up starting after the end of the download test
if(useFetchAPI){ if(useFetchAPI){
xhr[i]=fetch(settings.url_dl+"?r="+Math.random()+"&ckSize="+settings.garbagePhp_chunkSize).then(function(response) { xhr[i]=fetch(settings.url_dl+"?r="+Math.random()+"&ckSize="+settings.garbagePhp_chunkSize).then(function(response) {
@ -176,7 +176,7 @@ function dlTest(done){
}.bind(this); }.bind(this);
xhr[i].onload=function(){ xhr[i].onload=function(){
//the large file has been loaded entirely, start again //the large file has been loaded entirely, start again
xhr[i].abort();// reset the stream data to empty ram try{xhr[i].abort();}catch(e){} //reset the stream data to empty ram
testStream(i,0); testStream(i,0);
}.bind(this); }.bind(this);
xhr[i].onerror=function(){ xhr[i].onerror=function(){
@ -224,9 +224,9 @@ function ulTest(done){
startT=new Date().getTime(), //timestamp when test was started startT=new Date().getTime(), //timestamp when test was started
failed=false; //set to true if a stream fails failed=false; //set to true if a stream fails
xhr=[]; xhr=[];
//function to create an upload stream //function to create an upload stream. streams are slightly delayed so that they will not end at the same time
var testStream=function(i,delay){ var testStream=function(i,delay){
setTimeout(function(){ //delay creation of a stream slightly so that the new stream is completely detached from the one that created it setTimeout(function(){
if(testStatus!=3) return; //delayed stream ended up starting after the end of the upload test if(testStatus!=3) return; //delayed stream ended up starting after the end of the upload test
var prevLoaded=0; //number of bytes transmitted last time onprogress was called var prevLoaded=0; //number of bytes transmitted last time onprogress was called
var x=new XMLHttpRequest(); var x=new XMLHttpRequest();

File diff suppressed because one or more lines are too long