-
Notifications
You must be signed in to change notification settings - Fork 2
/
speed2.html
41 lines (39 loc) · 1.3 KB
/
speed2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="js/vendor/zepto.js"></script>
<script type="text/javascript">
function test()
{
console.log("begin test speed -->>")
var d = new Date;
var time1 = d.getTime();
var url = "/test1.jpg?s=" + time1;
console.log("from: " + time1);
$.get(
url,
function(data, textStatus){
var d = new Date;
//var time = Math.round((d.getTime()-time1)/10)/100;
console.log("to : " + d.getTime());
var cost = d.getTime() - time1;
console.log("cost: " + cost + "1/1000秒");
console.log("receive:" + data.length + "bytes")
var connSpeed = Math.round(data.length/cost/1000);
var speed = Math.round((data.length * 1000)/cost);
console.log("speed:" + speed + "bps")
console.log("speed:" + speed/1024 + "kbps")
console.log("speed:" + speed/1024/1024 + "Mbps")
// alert("Total time: \t\t\t"+cost/1000+" second"+
// "\nTotal bytes: \t\t\t"+data.length+" bytes"+
// "\nConnection speed: \t"+speed/1000+" kBps");
}
);
};
</script>
</head>
<body>
<button onclick="test()">Test</button>
</body>
</html>