diff --git a/doc.md b/doc.md index f7a8622..18d7c4a 100644 --- a/doc.md +++ b/doc.md @@ -1,7 +1,7 @@ # HTML5 Speedtest > by Federico Dossena -> Version 4.6.1, August 8, 2018 +> Version 4.6.2, September 21, 2018 > [https://github.com/adolfintel/speedtest/](https://github.com/adolfintel/speedtest/) @@ -180,8 +180,8 @@ w.postMessage('start '+JSON.stringify(params)) * Default: `15` * Recommended: `>=10` * __count_ping__: How many pings to perform in the ping test - * Default: `35` - * Recommended: `>=20` + * Default: `10` + * Recommended: `>=3, <30` * __url_dl__: path to garbage.php or a large file to use for the download test. * Default: `garbage.php` * __Important:__ path is relative to js file diff --git a/speedtest_worker.js b/speedtest_worker.js index c68b206..35776a2 100644 --- a/speedtest_worker.js +++ b/speedtest_worker.js @@ -1,5 +1,5 @@ /* - HTML5 Speedtest v4.6.1 + HTML5 Speedtest v4.6.2 by Federico Dossena https://github.com/adolfintel/speedtest/ GNU LGPLv3 License @@ -28,7 +28,7 @@ var settings = { time_dl: 15, // duration of download test in seconds time_ulGraceTime: 3, //time to wait in seconds before actually measuring ul speed (wait for buffers to fill) time_dlGraceTime: 1.5, //time to wait in seconds before actually measuring dl speed (wait for TCP window to increase) - count_ping: 35, // number of pings to perform in ping test + count_ping: 10, // number of pings to perform in ping test url_dl: 'garbage.php', // path to a large file or garbage.php, used for download test. must be relative to this js file url_ul: 'empty.php', // path to an empty file, used for upload test. must be relative to this js file url_ping: 'empty.php', // path to an empty file, used for ping test. must be relative to this js file @@ -442,8 +442,8 @@ function pingTest (done) { } var instjitter = Math.abs(instspd - prevInstspd) if (i === 1) ping = instspd; /* first ping, can't tell jitter yet*/ else { - ping = ping * 0.9 + instspd * 0.1 // ping, weighted average - jitter = instjitter > jitter ? (jitter * 0.2 + instjitter * 0.8) : (jitter * 0.9 + instjitter * 0.1) // update jitter, weighted average. spikes in ping values are given more weight. + ping = instspd < ping ? ping : ping * 0.8 + instspd * 0.2 // update ping, weighted average. if the instant ping is lower than the current average, it is set to that value instead of averaging + jitter = instjitter > jitter ? (jitter * 0.3 + instjitter * 0.7) : (jitter * 0.8 + instjitter * 0.2) // update jitter, weighted average. spikes in ping values are given more weight. } prevInstspd = instspd } diff --git a/speedtest_worker.min.js b/speedtest_worker.min.js index 79ba9aa..031668e 100644 --- a/speedtest_worker.min.js +++ b/speedtest_worker.min.js @@ -1 +1 @@ -var testStatus=-1,dlStatus="",ulStatus="",pingStatus="",jitterStatus="",clientIp="",dlProgress=0,ulProgress=0,pingProgress=0,testId="noID",log="";function tlog(s){log+=Date.now()+": "+s+"\n"}function twarn(s){log+=Date.now()+" WARN: "+s+"\n",console.warn(s)}var settings={test_order:"IP_D_U",time_ul:15,time_dl:15,time_ulGraceTime:3,time_dlGraceTime:1.5,count_ping:35,url_dl:"garbage.php",url_ul:"empty.php",url_ping:"empty.php",url_getIp:"getIP.php",getIp_ispInfo:!0,getIp_ispInfo_distance:"km",xhr_dlMultistream:10,xhr_ulMultistream:3,xhr_multistreamDelay:300,xhr_ignoreErrors:1,xhr_dlUseBlob:!1,xhr_ul_blob_megabytes:20,garbagePhp_chunkSize:20,enable_quirks:!0,ping_allowPerformanceApi:!0,overheadCompensationFactor:1.06,useMebibits:!1,telemetry_level:0,url_telemetry:"telemetry/telemetry.php",telemetry_extra:""},xhr=null,interval=null,test_pointer=0;function url_sep(url){return url.match(/\?/)?"&":"?"}function clearRequests(){if(tlog("stopping pending XHRs"),xhr){for(var i=0;i=settings.test_order.length)0settings.time_dl&&01e3*settings.time_dlGraceTime&&(0settings.time_ul&&01e3*settings.time_ulGraceTime&&(0=settings.test_order.length)0settings.time_dl&&01e3*settings.time_dlGraceTime&&(0settings.time_ul&&01e3*settings.time_ulGraceTime&&(0