Improved ping/jitter test

This commit is contained in:
dosse91 2017-06-14 12:33:11 +02:00
parent 710887f400
commit 23b188b3ce
4 changed files with 7 additions and 5 deletions

5
doc.md
View file

@ -1,7 +1,7 @@
# HTML5 Speedtest
> by Federico Dossena
> Version 4.2.2, June 13 2017
> Version 4.2.3, June 14 2017
> [https://github.com/adolfintel/speedtest/](https://github.com/adolfintel/speedtest/)
@ -206,7 +206,7 @@ It is important here to turn off compression, and generate incompressible data.
A symlink to `/dev/urandom` is also ok.
#### Replacement for `empty.php`
Your replacement must simply respond with a HTTP code 200 and send nothing else. You may want to send additional headers to disable caching.
Your replacement must simply respond with a HTTP code 200 and send nothing else. You may want to send additional headers to disable caching. The test assumes that Connection:keep-alive is sent by the server.
#### Replacement for `getIP.php`
Your replacement must simply respond with the client's IP as plaintext. Nothing fancy.
@ -220,6 +220,7 @@ w.postMessage('start {"url_dl": "newGarbageURL", "url_ul": "newEmptyURL", "url_p
## Known bugs and limitations
* The ping/jitter test is measured by seeing how long it takes for an empty XHR to complete. It is not an acutal ICMP ping
* __Chrome:__ high CPU usage from XHR requests with very fast connections (like gigabit).
For this reason, the test may report inaccurate results if your CPU is too slow. (Does not affect most computers)
* __IE11:__ the upload test is not precise on very fast connections

View file

@ -3,4 +3,5 @@ header( "HTTP/1.1 200 OK" );
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Connection: keep-alive");
?>

View file

@ -1,5 +1,5 @@
/*
HTML5 Speedtest v4.2.2
HTML5 Speedtest v4.2.3
by Federico Dossena
https://github.com/adolfintel/speedtest/
GNU LGPLv3 License
@ -325,7 +325,7 @@ function pingTest (done) {
if (i === 0) {
prevT = new Date().getTime() // first pong
} else {
var instspd = (new Date().getTime() - prevT) / 2
var instspd = (new Date().getTime() - prevT)
var instjitter = Math.abs(instspd - prevInstspd)
if (i === 1) ping = instspd; /* first ping, can't tell jiutter yet*/ else {
ping = ping * 0.9 + instspd * 0.1 // ping, weighted average

File diff suppressed because one or more lines are too long