<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="emu">
<META NAME="Keywords" CONTENT="emu">
<META NAME="Description" CONTENT="net work tester">
<TITLE> 网络速度测试 </TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var resources = [
"http://www.csdn.net/",
"http://community.csdn.net/",
"http://blog.csdn.net/",
"http://chat.csdn.net/",
"http://mag.csdn.net/",
"http://blogdev.csdn.net/",
"http://mobile.csdn.net/",
"http://training.csdn.net/",
"http://job.csdn.net/",
"http://wiki.csdn.net/",
"http://dev.csdn.net/",
"http://news.csdn.net/",
"http://61.186.252.131/"
];
var result = [];
var succCount,failCount,t0,checktimes = 10;
var minLength = 1;
var timeCount,fso,fsos,fileName;
try{
fso = new ActiveXObject("Scripting.FileSystemObject");
}catch(e){
alert("对不起,您的操作系统不支持文件系统对象,无法完成测试");
close();
}
function testAsync(){
var s = location.href.replace(/file:\/*/,"");
s = s.substring(0,s.lastIndexOf("/")+1).replace(/\//g,"\\").replace(/%20/g," ")
if(/\\temp\\rar\$/i.test(s)){alert("请把文件解压到本地目录再运行");close();return;}
with(document.getElementById("f"))
if(defaultValue ==value || value==""){alert("请先填写测试地点");focus();select();return;}
if((document.fo.nType[0].checked||netType.value==netType.defaultValue) && !confirm("您真的无法确认您所使用的网络类型吗?"))return;
if(netType.value==""){alert("请选择网络类型");return;}
fileName = s+document.getElementById("f").value+"的测试报告.htm"
clipboardData.setData('Text',fileName);
fsos = fso.CreateTextFile(fileName,true);
fsos.WriteLine("<html>\n<head>\n \t<title>"+document.getElementById("f").value+"的测试报告</title> \n</head>")
var d = new Date();
fsos.WriteLine("<body>\n<table align=center bgcolor=black cellspacing=1><tbody bgcolor=white>\n\t<tr>\n\t\t<td colspan="+(checktimes+2)+">\n\t\t\t");
fsos.WriteLine(d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日 "+d.getHours()+":"+d.getMinutes()+" "+document.getElementById("f").value+"的测试报告。网络类型:"+netType.value);
fsos.WriteLine("\t\t</td>\n\t</tr>");
fsos.WriteLine("\t<tr>\n\t\t<td>资源地址</td>");
for(var i=0;i<checktimes;i++)
fsos.WriteLine("\t\t<td>第"+(i+1)+"轮</td>");
fsos.WriteLine("\t\t<td>平均时延</td>\n\t</tr>");
document.getElementById("testButton").disabled=true;
testResource(0);
}
function testResource(u){
window.currentRound = u;
if(u>=resources.length) {
document.title = "测试已完成。";
fsos.WriteLine("</table></body></html>");
fsos.Close();
document.getElementById("testButton").disabled=false;
if (confirm("测试完成,测试报告已经保存到“"+fileName+"”,您想现在把这个文件发送到 test@test.com吗?")){
window.open(fileName).document.title="这是测试结果,请吧这个文件作为附件发送到test@test.com";
window.open("mailto:test@test.com?subject="+document.getElementById("f").value+" 的测试报告&body=test你好,附件中是我们的测试结果。&attach='"+fileName+"'");
}
close();
return;
}
document.title = "共"+resources.length+"组,正在测试第"+(u+1)+"组。进度 "+Math.round(100*u/resources.length)+"%";
succCount=failCount=timeCount=0;
var url = resources[u];
output.innerHTML += "<br/>正在测试"+url+"<br/>";
fsos.WriteLine("\t\<tr>\n\t\t<td>"+url+"</td>");
for(var i=0;i<checktimes;i++){
window["xmlhttp"+i] = new ActiveXObject("microsoft.XMLHTTP");
window["xmlhttp_startAt"+i]= new Date();
window["xmlhttp"+i].onreadystatechange = new Function("f("+i+")");
//window["xmlhttp"+i].open("get",url+(/\?/.test(url)?"&":"?")+"p="+Math.random(),true);
window["xmlhttp"+i].open("get",url,true);
window["xmlhttp"+i].setRequestHeader("If-Modified-Since","0");
window["xmlhttp"+i].send("");
}
}
function f(i){
var xmlhttp = window["xmlhttp"+i];
if (xmlhttp.readyState == 4)
{
var d = new Date();
timeCount += (d-window["xmlhttp_startAt"+i]);
var itemTimeCount = d-window["xmlhttp_startAt"+i];
var responseLength = xmlhttp.responseText.length;
if(responseLength>minLength){
output.innerHTML += "第"+i+"次 成功获得"+responseLength+"字节数据,耗时"+itemTimeCount+"毫秒<br/>";
fsos.WriteLine("\t\t<td><font color=green>"+itemTimeCount+"</font></td>");
succCount++;
}else{
output.innerHTML += "第"+i+"次 <FONT SIZE=5 COLOR=red>失败</FONT> 耗时"+itemTimeCount+"毫秒。获得"+responseLength+"字节数据<br/>";
fsos.WriteLine("\t\t<td><font color=red>"+itemTimeCount+"</font></td>");
failCount++
}
output.scrollTop = output.scrollHeight;
if(succCount+failCount==checktimes){
var avg = Math.round(timeCount/checktimes*100)/100;
output.innerHTML += "<BR>成功<font color=green>"+succCount+"</font>次,失败<font color=red>"+failCount+"</font>次,平均时延"+avg+"毫秒<hr>";
fsos.WriteLine("\t\t<td>"+avg+"</td>");
testResource(window.currentRound+1);
}else{
var s = Math.round((window.currentRound*checktimes+succCount+failCount)/(checktimes*resources.length)*100);
document.title = document.title.replace(/(\d+%)/,s+"%");
}
}
}
//-->
</SCRIPT>
测试前请先填写测试地点和测试人:
<form name="fo">
<input id="f" size=70 value="××省××市××区 ×××" οnclick="select()">
<BR><BR>网络类型:
<input type="radio" name="nType" value="未知" id="nType1" οnclick="netType.value=value" checked><label for="nType1">未知</label>
<input type="radio" name="nType" value="电信" id="nType2" οnclick="netType.value=value"><label for="nType2">电信</label>
<input type="radio" name="nType" value="联通" id="nType3" οnclick="netType.value=value"><label for="nType3">联通</label>
<input type="radio" name="nType" value="网通" id="nType4" οnclick="netType.value=value"><label for="nType4">网通</label>
<input type="radio" name="nType" value="铁通" id="nType6" οnclick="netType.value=value"><label for="nType6">铁通</label>
<input type="radio" name="nType" value="有线电视" id="nType7" οnclick="netType.value=value"><label for="nType7">有线电视</label><BR>
<input type="radio" name="nType" value="小区局域网" id="nType8" οnclick="netType.value=value"><label for="nType8">小区局域网(小区宽带)</label>
<input type="radio" name="nType" value="教育网" id="nType9" οnclick="netType.value=value"><label for="nType9">教育网</label>
<input type="radio" name="nType" value="科技网" id="nType0" οnclick="netType.value=value"><label for="nType0">科技网</label>
<input type="radio" name="nType" value="" id="nType99" οnclick="netType.value='';netType.focus();"><label for="nType99">其他(请注明)</label>
</form>
网络类型:<input id="netType" value="未知">
<br/><br/><button οnclick="testAsync()" id="testButton">测试</button>
<BR><BR>
<div id="output" style="border:1 solid gray;width:95%;height:400;overflow-y:scroll"></div>
</BODY>
</HTML>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="emu">
<META NAME="Keywords" CONTENT="emu">
<META NAME="Description" CONTENT="net work tester">
<TITLE> 网络速度测试 </TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var resources = [
"http://www.csdn.net/",
"http://community.csdn.net/",
"http://blog.csdn.net/",
"http://chat.csdn.net/",
"http://mag.csdn.net/",
"http://blogdev.csdn.net/",
"http://mobile.csdn.net/",
"http://training.csdn.net/",
"http://job.csdn.net/",
"http://wiki.csdn.net/",
"http://dev.csdn.net/",
"http://news.csdn.net/",
"http://61.186.252.131/"
];
var result = [];
var succCount,failCount,t0,checktimes = 10;
var minLength = 1;
var timeCount,fso,fsos,fileName;
try{
fso = new ActiveXObject("Scripting.FileSystemObject");
}catch(e){
alert("对不起,您的操作系统不支持文件系统对象,无法完成测试");
close();
}
function testAsync(){
var s = location.href.replace(/file:\/*/,"");
s = s.substring(0,s.lastIndexOf("/")+1).replace(/\//g,"\\").replace(/%20/g," ")
if(/\\temp\\rar\$/i.test(s)){alert("请把文件解压到本地目录再运行");close();return;}
with(document.getElementById("f"))
if(defaultValue ==value || value==""){alert("请先填写测试地点");focus();select();return;}
if((document.fo.nType[0].checked||netType.value==netType.defaultValue) && !confirm("您真的无法确认您所使用的网络类型吗?"))return;
if(netType.value==""){alert("请选择网络类型");return;}
fileName = s+document.getElementById("f").value+"的测试报告.htm"
clipboardData.setData('Text',fileName);
fsos = fso.CreateTextFile(fileName,true);
fsos.WriteLine("<html>\n<head>\n \t<title>"+document.getElementById("f").value+"的测试报告</title> \n</head>")
var d = new Date();
fsos.WriteLine("<body>\n<table align=center bgcolor=black cellspacing=1><tbody bgcolor=white>\n\t<tr>\n\t\t<td colspan="+(checktimes+2)+">\n\t\t\t");
fsos.WriteLine(d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日 "+d.getHours()+":"+d.getMinutes()+" "+document.getElementById("f").value+"的测试报告。网络类型:"+netType.value);
fsos.WriteLine("\t\t</td>\n\t</tr>");
fsos.WriteLine("\t<tr>\n\t\t<td>资源地址</td>");
for(var i=0;i<checktimes;i++)
fsos.WriteLine("\t\t<td>第"+(i+1)+"轮</td>");
fsos.WriteLine("\t\t<td>平均时延</td>\n\t</tr>");
document.getElementById("testButton").disabled=true;
testResource(0);
}
function testResource(u){
window.currentRound = u;
if(u>=resources.length) {
document.title = "测试已完成。";
fsos.WriteLine("</table></body></html>");
fsos.Close();
document.getElementById("testButton").disabled=false;
if (confirm("测试完成,测试报告已经保存到“"+fileName+"”,您想现在把这个文件发送到 test@test.com吗?")){
window.open(fileName).document.title="这是测试结果,请吧这个文件作为附件发送到test@test.com";
window.open("mailto:test@test.com?subject="+document.getElementById("f").value+" 的测试报告&body=test你好,附件中是我们的测试结果。&attach='"+fileName+"'");
}
close();
return;
}
document.title = "共"+resources.length+"组,正在测试第"+(u+1)+"组。进度 "+Math.round(100*u/resources.length)+"%";
succCount=failCount=timeCount=0;
var url = resources[u];
output.innerHTML += "<br/>正在测试"+url+"<br/>";
fsos.WriteLine("\t\<tr>\n\t\t<td>"+url+"</td>");
for(var i=0;i<checktimes;i++){
window["xmlhttp"+i] = new ActiveXObject("microsoft.XMLHTTP");
window["xmlhttp_startAt"+i]= new Date();
window["xmlhttp"+i].onreadystatechange = new Function("f("+i+")");
//window["xmlhttp"+i].open("get",url+(/\?/.test(url)?"&":"?")+"p="+Math.random(),true);
window["xmlhttp"+i].open("get",url,true);
window["xmlhttp"+i].setRequestHeader("If-Modified-Since","0");
window["xmlhttp"+i].send("");
}
}
function f(i){
var xmlhttp = window["xmlhttp"+i];
if (xmlhttp.readyState == 4)
{
var d = new Date();
timeCount += (d-window["xmlhttp_startAt"+i]);
var itemTimeCount = d-window["xmlhttp_startAt"+i];
var responseLength = xmlhttp.responseText.length;
if(responseLength>minLength){
output.innerHTML += "第"+i+"次 成功获得"+responseLength+"字节数据,耗时"+itemTimeCount+"毫秒<br/>";
fsos.WriteLine("\t\t<td><font color=green>"+itemTimeCount+"</font></td>");
succCount++;
}else{
output.innerHTML += "第"+i+"次 <FONT SIZE=5 COLOR=red>失败</FONT> 耗时"+itemTimeCount+"毫秒。获得"+responseLength+"字节数据<br/>";
fsos.WriteLine("\t\t<td><font color=red>"+itemTimeCount+"</font></td>");
failCount++
}
output.scrollTop = output.scrollHeight;
if(succCount+failCount==checktimes){
var avg = Math.round(timeCount/checktimes*100)/100;
output.innerHTML += "<BR>成功<font color=green>"+succCount+"</font>次,失败<font color=red>"+failCount+"</font>次,平均时延"+avg+"毫秒<hr>";
fsos.WriteLine("\t\t<td>"+avg+"</td>");
testResource(window.currentRound+1);
}else{
var s = Math.round((window.currentRound*checktimes+succCount+failCount)/(checktimes*resources.length)*100);
document.title = document.title.replace(/(\d+%)/,s+"%");
}
}
}
//-->
</SCRIPT>
测试前请先填写测试地点和测试人:
<form name="fo">
<input id="f" size=70 value="××省××市××区 ×××" οnclick="select()">
<BR><BR>网络类型:
<input type="radio" name="nType" value="未知" id="nType1" οnclick="netType.value=value" checked><label for="nType1">未知</label>
<input type="radio" name="nType" value="电信" id="nType2" οnclick="netType.value=value"><label for="nType2">电信</label>
<input type="radio" name="nType" value="联通" id="nType3" οnclick="netType.value=value"><label for="nType3">联通</label>
<input type="radio" name="nType" value="网通" id="nType4" οnclick="netType.value=value"><label for="nType4">网通</label>
<input type="radio" name="nType" value="铁通" id="nType6" οnclick="netType.value=value"><label for="nType6">铁通</label>
<input type="radio" name="nType" value="有线电视" id="nType7" οnclick="netType.value=value"><label for="nType7">有线电视</label><BR>
<input type="radio" name="nType" value="小区局域网" id="nType8" οnclick="netType.value=value"><label for="nType8">小区局域网(小区宽带)</label>
<input type="radio" name="nType" value="教育网" id="nType9" οnclick="netType.value=value"><label for="nType9">教育网</label>
<input type="radio" name="nType" value="科技网" id="nType0" οnclick="netType.value=value"><label for="nType0">科技网</label>
<input type="radio" name="nType" value="" id="nType99" οnclick="netType.value='';netType.focus();"><label for="nType99">其他(请注明)</label>
</form>
网络类型:<input id="netType" value="未知">
<br/><br/><button οnclick="testAsync()" id="testButton">测试</button>
<BR><BR>
<div id="output" style="border:1 solid gray;width:95%;height:400;overflow-y:scroll"></div>
</BODY>
</HTML>