|
@@ -43,14 +43,33 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
<br>
|
|
- <button class="ui fluid button" onclick="startBench();">Test</button>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <div class="ui top attached teal progress" id="progressbar" style="display: none">
|
|
|
|
+ <div class="bar">
|
|
|
|
+ <div class="progress"></div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <button class="ui fluid button" onclick="startBench();" id="startbtn">Test</button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</body>
|
|
</body>
|
|
<script>
|
|
<script>
|
|
ao_module_setFixedWindowSize();
|
|
ao_module_setFixedWindowSize();
|
|
|
|
+ $('#progressbar').progress({
|
|
|
|
+ label: 'ratio',
|
|
|
|
+ text: {
|
|
|
|
+ ratio: ''
|
|
|
|
+ },
|
|
|
|
+ total: 100,
|
|
|
|
+ percent: 0
|
|
|
|
+ });
|
|
|
|
|
|
function startBench() {
|
|
function startBench() {
|
|
|
|
+ $('#progressbar').removeAttr('style');
|
|
|
|
+ $('#progressbar').progress('set progress', 0);
|
|
|
|
+ $("#startbtn").attr('disabled', 'disabled');
|
|
|
|
+ $("#startbtn").html('Testing...');
|
|
downloadBench();
|
|
downloadBench();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -61,6 +80,7 @@
|
|
socket.onopen = function(e) {
|
|
socket.onopen = function(e) {
|
|
$("#dl").text("⌛");
|
|
$("#dl").text("⌛");
|
|
socket.send("DWL");
|
|
socket.send("DWL");
|
|
|
|
+ $('#progressbar').progress('set progress', 0);
|
|
};
|
|
};
|
|
|
|
|
|
socket.onmessage = function(event) {
|
|
socket.onmessage = function(event) {
|
|
@@ -70,13 +90,18 @@
|
|
$("#dl").text(bandwidth[0]);
|
|
$("#dl").text(bandwidth[0]);
|
|
$("#dll").text("Download (" + bandwidth[1] + ")");
|
|
$("#dll").text("Download (" + bandwidth[1] + ")");
|
|
uploadBench();
|
|
uploadBench();
|
|
- //pingTest();
|
|
|
|
|
|
+ }
|
|
|
|
+ if (event.data.indexOf("TIME_DIFF") != -1) {
|
|
|
|
+ let timediff = parseInt(event.data.split("=")[1]);
|
|
|
|
+ $('#progressbar').progress('increment', timediff / 5 * 100);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
socket.onerror = function(error) {
|
|
socket.onerror = function(error) {
|
|
- $("#dl").text("❌");
|
|
|
|
|
|
+ if ($("#dl").text() != "⌛") {
|
|
|
|
+ $("#dl").text("❌");
|
|
|
|
+ }
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,32 +116,40 @@
|
|
};
|
|
};
|
|
|
|
|
|
socket.onerror = function(error) {
|
|
socket.onerror = function(error) {
|
|
- $("#ul").text("❌");
|
|
|
|
|
|
+ if ($("#ul").text() != "⌛") {
|
|
|
|
+ $("#ul").text("❌");
|
|
|
|
+ }
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
function executeULTest(socket) {
|
|
function executeULTest(socket) {
|
|
- let CurrentMB = 0;
|
|
|
|
|
|
+ $('#progressbar').progress('set progress', 0);
|
|
|
|
+ let CurrentMB = 0;
|
|
let start = new Date();
|
|
let start = new Date();
|
|
- while(socket.bufferedAmount < 10485760 * 10) {
|
|
|
|
- socket.send(new ArrayBuffer(32768));
|
|
|
|
- CurrentMB += 32768;
|
|
|
|
- }
|
|
|
|
- let checker = setInterval(function(){
|
|
|
|
- if(socket.bufferedAmount == 0) {
|
|
|
|
- let end = new Date();
|
|
|
|
- CurrentDif = (end.getTime() - start.getTime()) / 1000;
|
|
|
|
- socket.send("stop");
|
|
|
|
- let bandwidth = bytesToSpeed(CurrentMB / CurrentDif).split(" ");
|
|
|
|
- $("#ul").text(bandwidth[0]);
|
|
|
|
- $("#ull").text("Upload (" + bandwidth[1] + ")");
|
|
|
|
- clearInterval(checker);
|
|
|
|
- pingTest();
|
|
|
|
- }
|
|
|
|
- }, 100);
|
|
|
|
|
|
+ while (socket.bufferedAmount < 10485760 * 10) {
|
|
|
|
+ socket.send(new ArrayBuffer(32768));
|
|
|
|
+ CurrentMB += 32768;
|
|
|
|
+ }
|
|
|
|
+ let checker = setInterval(function() {
|
|
|
|
+ if (socket.bufferedAmount == 0) {
|
|
|
|
+ let end = new Date();
|
|
|
|
+ CurrentDif = (end.getTime() - start.getTime()) / 1000;
|
|
|
|
+ socket.send("stop");
|
|
|
|
+ let bandwidth = bytesToSpeed(CurrentMB / CurrentDif).split(" ");
|
|
|
|
+ $("#ul").text(bandwidth[0]);
|
|
|
|
+ $("#ull").text("Upload (" + bandwidth[1] + ")");
|
|
|
|
+ $('#progressbar').progress('set progress', 0);
|
|
|
|
+ clearInterval(checker);
|
|
|
|
+ pingTest();
|
|
|
|
+ } else {
|
|
|
|
+ //(1 - (socket.bufferedAmount / (10485760 * 10))) * 100
|
|
|
|
+ $('#progressbar').progress('set progress', 100 - (socket.bufferedAmount / 1048576));
|
|
|
|
+ }
|
|
|
|
+ }, 100);
|
|
}
|
|
}
|
|
|
|
|
|
function pingTest() {
|
|
function pingTest() {
|
|
|
|
+ $('#progressbar').progress('set progress', 0);
|
|
let clientSendTimeStamp = [];
|
|
let clientSendTimeStamp = [];
|
|
let serverResponseTimeStamp = [];
|
|
let serverResponseTimeStamp = [];
|
|
let clientReceiveTimeStamp = [];
|
|
let clientReceiveTimeStamp = [];
|
|
@@ -132,10 +165,16 @@
|
|
socket.onmessage = function(event) {
|
|
socket.onmessage = function(event) {
|
|
clientReceiveTimeStamp.push(new Date().getTime());
|
|
clientReceiveTimeStamp.push(new Date().getTime());
|
|
serverResponseTimeStamp.push(event.data);
|
|
serverResponseTimeStamp.push(event.data);
|
|
|
|
+ if (clientReceiveTimeStamp.length == 5) {
|
|
|
|
+ setTimeout(showPingResult, 2000, clientSendTimeStamp, serverResponseTimeStamp, clientReceiveTimeStamp);
|
|
|
|
+ }
|
|
|
|
+ $('#progressbar').progress('increment', 16.67);
|
|
};
|
|
};
|
|
|
|
|
|
socket.onerror = function(error) {
|
|
socket.onerror = function(error) {
|
|
- $("#ping").text("❌");
|
|
|
|
|
|
+ if ($("#ping").text() != "⌛") {
|
|
|
|
+ $("#ping").text("❌");
|
|
|
|
+ }
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -144,10 +183,9 @@
|
|
socket.send(clientTime);
|
|
socket.send(clientTime);
|
|
clientSendTimeStamp.push(clientTime.getTime());
|
|
clientSendTimeStamp.push(clientTime.getTime());
|
|
count++;
|
|
count++;
|
|
|
|
+ $('#progressbar').progress('increment', 16.67);
|
|
if (count < 3) {
|
|
if (count < 3) {
|
|
setTimeout(executePingTest, 1000, socket, clientSendTimeStamp, serverResponseTimeStamp, clientReceiveTimeStamp, count);
|
|
setTimeout(executePingTest, 1000, socket, clientSendTimeStamp, serverResponseTimeStamp, clientReceiveTimeStamp, count);
|
|
- } else {
|
|
|
|
- setTimeout(showPingResult, 2000, clientSendTimeStamp, serverResponseTimeStamp, clientReceiveTimeStamp);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -162,6 +200,11 @@
|
|
}
|
|
}
|
|
$("#ping").text(Math.round((diff / clientSendTimeStamp.length) * 100) / 100);
|
|
$("#ping").text(Math.round((diff / clientSendTimeStamp.length) * 100) / 100);
|
|
$("#pingl").text("Ping (ms)");
|
|
$("#pingl").text("Ping (ms)");
|
|
|
|
+ //restart the test
|
|
|
|
+ $('#progressbar').attr('style', 'display: none');
|
|
|
|
+ $("#startbtn").html('Re-Test');
|
|
|
|
+ $("#startbtn").attr('onclick', 'location.reload();');
|
|
|
|
+ $("#startbtn").removeAttr('disabled');
|
|
}
|
|
}
|
|
|
|
|
|
function getWSEndpoint() {
|
|
function getWSEndpoint() {
|