<%@ Language=VBScript %>
<!--#INCLUDE FILE="ping.asp"-->
<%
if Request.Cookies("formdefault") <> "true" then
Response.Write "不是从公共网页进入,不能浏览本页内容。"
Response.end
//取消允许进入
else
Response.Cookies("formdefault") = "false"
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>aaa系统首页</title>
</head>
<body bgcolor=#000000 text="#000FFF" >
<Script Language=javascript>
function Click(){
alert('版权所有(C)2004 aaa公司');
window.event.returnValue=false;
}
document.oncontextmenu=Click;
</Script>
<%
Response.Expires=-1
Response.ExpiresAbsolute=Now()-1
Response.cachecontrol="no-cache"
Dim Imgrandom
Randomize
Imgrandom = Int(799999 * Rnd + 200000)
//显示时延
pingResult = request.cookies("pingResult")
%>
<table width="97%" border="0">
<tr>
<td><font face="幼圆">欢迎您(<%=request.servervariables("remote_addr")%>)在<%=now%></font></td>
</tr>
<tr>
<td><font face="幼圆">使用aaa系统。</font></td>
</tr>
<tr>
<td><font face="幼圆">----------------------------------------</font></td>
</tr>
<tr>
<td><font face="幼圆">从aaa到达新浪的平均时延是:</font></td>
</tr>
<tr>
<td><font face="幼圆"><%=pingResult%></font></td>
</tr>
<tr>
<td><font face="幼圆">您在aaa的下载速度为:</font></td>
</tr>
<tr>
<td><font face="幼圆"><span id=showtxt></span></font></td>
</tr>
</table>
<SCRIPT LANGUAGE="JScript">
window.status = "正在测速,请等候..."
var st = new Date()
</SCRIPT>
<img src="precise.jpg?id=<%=Imgrandom%>" width=0 height=0 onerror = showerr() onload="showspeed();">
<SCRIPT LANGUAGE="jscript">
var speed = 0
function showspeed()
{
var fs = 9437.238 //img.jpg文件大小(K)
var l = 2 //小数点的位数
var et = new Date()
alltime = et - st
calcspeed = Math.round((9*fs/alltime)*100)/100 //转换成bit,除以时长
showtxt.innerHTML = (calcspeed+" (Mbits/秒)或"+1000*calcspeed/8 +"(Kbytes/秒)")
window.status = "您在本站的下载速度为:"+calcspeed+" (Mbit/秒)"
}
function showerr()
{
showtxt.innerHTML = ("数据下载错误,请刷新重试")
window.status = "数据下载错误,请刷新重试"
}
</SCRIPT>
</body>
</html>
----------------解决方案--------------------------------------------------------
我的分析:
开始测试时间记录在st
下载图片,完成后调用showspeed
用当前时间-开始时间得出时间差,就是下载图片所花的时间,文件的长度是9437.238K,一除就是每秒的速率了
不知道对不对,瞎说,高手不要见笑
----------------解决方案--------------------------------------------------------