如何统计移动端浏览器的并发请求数
更新:HHH   时间:2023-1-7


针对这个问题,今天小编总结这篇有关统计移动端浏览器的并发请求数的文章,希望能帮助更多想解决这个问题的朋友找到更加简单易行的办法。

网上未见针对移动端的浏览器并发数统计,可见的帖子数据全部来自于 StackOverflow 关于主机浏览器的一篇描述。

所以,设计了实验,探测了部分手机浏览器,对同域的并发访问量。

以下是实验程序
服务端(Java)

static private final AtomicLong SEQ = new AtomicLong(0);

@RequestMapping(value = "sleep/{s}", method = GET)
public Result<Long> sleepForSeconds(@PathVariable("s") int secondNum)
{
    long index = SEQ.incrementAndGet();
    try { Thread.sleep(secondNum * 1000); }
    catch (InterruptedException iex) { }
    Result<Long> result = new Result<>();
    result.setData(index);
    result.setSuccess(true);
    return result;
}

前端(JavaScript with jQuery)

<div id="area_display"></div>
<script>
var nowInMillis = new Date().getTime();
for (var i = -1; ++i != 28; )
{
    $.get(apictx + '/try/sleep/4?t=' + nowInMillis + '_' + i).done(function(result)
    {
        var html = $('#area_display').html();
        html += result.data + '(use ';
        html += new Date().getTime() - nowInMillis + 'ms)<br />';
        $('#area_display').html(html);
    });
}
</script>

上文描述的就是统计移动端浏览器的并发请求数的详细内容,具体使用情况还需要大家自己动手实验使用过才能领会。如果想了解更多相关内容,欢迎关注天达云行业资讯频道!

返回开发技术教程...