Data is now incompressible
This commit is contained in:
parent
ec223a45d4
commit
d9c320aee4
3 changed files with 26 additions and 28 deletions
|
@ -1,8 +1,8 @@
|
|||
# Speedtest in 4k
|
||||
# HTML5 Speedtest
|
||||
|
||||
No Flash, No Java, No Websocket, No Bullshit.
|
||||
|
||||
This is a very small Speedtest implemented in Javascript, using XMLHttpRequest and Web Workers.
|
||||
This is a very lightweight Speedtest implemented in Javascript, using XMLHttpRequest and Web Workers.
|
||||
|
||||
## Try it
|
||||
[Take a Speedtest](http://speedtest.adolfintel.com)
|
||||
|
@ -13,9 +13,9 @@ Only modern browsers are supported (Edge 12+)
|
|||
## Requirements
|
||||
- A reasonably fast web server
|
||||
- Some way to generate garbage data using either the included PHP script, a [big file of random data](http://downloads.adolfintel.com/geth.php?r=speedtest-bigfile), or a symlink to /dev/urandom
|
||||
- Your server must not compress the data it sends
|
||||
- Your server must accept large POST requests (up to 10 Megabytes), otherwise the upload test will fail
|
||||
- Client side, there must not be any type of buffering (such as a proxy), or you may get incorrect results
|
||||
- It's also better if your server does not use compression, but it's not mandatory
|
||||
|
||||
## How to use
|
||||
See the examples, it's really simple.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// Disable Compression (would be too easy for 000...)
|
||||
// Disable Compression
|
||||
@ini_set('zlib.output_compression', 'Off');
|
||||
@ini_set('output_buffering', 'Off');
|
||||
@ini_set('output_handler', '');
|
||||
|
@ -15,8 +15,8 @@ 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");
|
||||
// Generate data
|
||||
$data=str_repeat("0",1048575)."\n";
|
||||
// Deliver chunks of 1048576 bytes (or more - depending on encoding!)
|
||||
$data=openssl_random_pseudo_bytes(1048576,false);
|
||||
// Deliver chunks of 1048576 bytes
|
||||
while(1){
|
||||
echo $data;
|
||||
flush();
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
var testStatus=0,dlStatus="",ulStatus="",pingStatus="";
|
||||
var settings={time_ul:15, time_dl:15, count_ping:35, url_dl:"garbage.php",url_ul:"empty.dat",url_ping:"empty.dat"};
|
||||
var settings={time_ul:15,time_dl:15,count_ping:35,url_dl:"garbage.php",url_ul:"empty.dat",url_ping:"empty.dat"};
|
||||
var xhr=null;
|
||||
this.addEventListener('message', function(e){
|
||||
var params=e.data.split(" ");
|
||||
if(params[0]=="status"){
|
||||
postMessage(testStatus+";"+dlStatus+";"+ulStatus+";"+pingStatus);
|
||||
}
|
||||
if(params[0]=="start"){
|
||||
if(testStatus==0){
|
||||
if(params[0]=="start"&&testStatus==0){
|
||||
testStatus=1;
|
||||
try{
|
||||
var s=JSON.parse(e.data.substring(5));
|
||||
|
@ -20,13 +19,11 @@ this.addEventListener('message', function(e){
|
|||
}catch(e){}
|
||||
dlTest(function(){testStatus=2;ulTest(function(){testStatus=3;pingTest(function(){testStatus=4;});});});
|
||||
}
|
||||
}
|
||||
if(params[0]=="abort"){
|
||||
try{if(xhr)xhr.abort();}catch(e){}
|
||||
testStatus=5;dlStatus="";ulStatus="";pingStatus="";
|
||||
}
|
||||
});
|
||||
|
||||
function dlTest(done){
|
||||
var firstTick=true,startT=new Date().getTime(), prevT=new Date().getTime(),prevLoaded=0,speed=0.0;
|
||||
xhr=new XMLHttpRequest();
|
||||
|
@ -54,10 +51,9 @@ function dlTest(done){
|
|||
xhr=null;
|
||||
done();
|
||||
}.bind(this);
|
||||
xhr.open("GET", settings.url_dl+"?r="+Math.random(),true);
|
||||
xhr.open("GET",settings.url_dl+"?r="+Math.random(),true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function ulTest(done){
|
||||
var firstTick=true,startT=new Date().getTime(), prevT=new Date().getTime(),prevLoaded=0,speed=0.0;
|
||||
xhr=new XMLHttpRequest();
|
||||
|
@ -82,10 +78,12 @@ function ulTest(done){
|
|||
ulStatus="Fail";
|
||||
done();
|
||||
}.bind(this);
|
||||
xhr.open("POST", settings.url_ul+"?r="+Math.random(),true);
|
||||
xhr.send(new ArrayBuffer(10485760));
|
||||
xhr.open("POST",settings.url_ul+"?r="+Math.random(),true);
|
||||
xhr.setRequestHeader('Content-Encoding','identity');
|
||||
var r=new ArrayBuffer(10485760);
|
||||
try{var w=new Float32Array(r);for(var i=0;i<w.length;i++)w[i]=Math.random();}catch(e){}
|
||||
xhr.send(r);
|
||||
}
|
||||
|
||||
function pingTest(done){
|
||||
var prevT=null,ping=0.0,i=0;
|
||||
var doPing=function(){
|
||||
|
|
Loading…
Reference in a new issue