网络测试
# 延时测试
<script>
$.ping = function(option)
{
var ping, requestTime, responseTime ;
$.ajax({
url: option.url+'/speed_test'+ (new Date()).getTime() + '.html',
type: 'GET',
dataType: 'html',
timeout: 10000,
beforeSend : function()
{
console.log('speed_test:' + option.url);
if(option.beforePing) option.beforePing();
requestTime = new Date().getTime();
},
complete : function()
{
responseTime = new Date().getTime();
ping = Math.abs(requestTime - responseTime);
if(option.afterPing) option.afterPing(ping);
}
});
if(option.interval && option.interval > 0)
{
var interval = option.interval * 1000;
setTimeout(function(){$.ping(option)}, interval);
}
};
</script>
<div id="msg" ></div>
<script type="text/javascript">
var domain = window.location.href;
</script>
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
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
上次更新: 2021/02/25, 00:14:46