我必须使用javascript和php进行带宽测试,我使用jQuery,并尝试所有浏览器,但是:
您是否有任何想法可以提高这些浏览器或其他优秀技术的性能来衡量速度?
sendFile: function (s, d, m){ // size, data, metric
m++; // how many times I tried to post data
console.log('m: '+m);
time = new Date();
endTime3=time.getTime(); // execute time start
if(s<=65536){
$.ajax({
type : 'POST',
url : '/vegpont/savszelesseg/',
timeout: 30000,
dataType: 'text',
cache: false,
data: {
index : 3,
text: d // large data, min 512 KB to
},
success : function(data){
console.log('kB: '+s);
time = new Date();
endTime4=time.getTime(); // execute time end
console.log('sec: '+(endTime4-endTime3)/1000);
if(((endTime4-endTime3)/1000)<sec){ // sec now equals 4
speedTest.createFile(s*2, m); // create a data which is 's' (aka size) large then call this sendfile method
}else{
var delta=(endTime4-endTime3)/1000;
var res=Math.round(s/delta);
$('div#speedResult3').html('<b>UP:</b><br/>kB: '+s+', '+
'sec: '+delta+'<br/>' +
'<b>~ '+res*8+' kbps</b>');
$('div#speedResult3').slideDown(1000);
$('div.buttonContainer').unblock();
}
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
if(textStatus=='timeout'){
if(m>10){
$('div#speedResult3').html('<b>UP:</b><br/>sikertelen mérés');
$('div#speedResult3').slideDown(1000);
$('div.buttonContainer').unblock();
}
else{
speedTest.createFile(s, m); // create a data which is 's' (aka size) large then call this sendfile method
}
}
}
});
}else{ ...