测量AJAX调用的处理时间 [英] measure processing time of AJAX call

查看:60
本文介绍了测量AJAX调用的处理时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想衡量处理 AJAX调用需要多长时间。我已经启动并运行但不知道如何在javascript中编码(仅限js)

I want to measure how long it takes to process AJAX call. I have it up and running but don't know how to code this in javascript (js only)

推荐答案

var start = new Date().getTime();
doAjax({
  success: function() {
    var end = new Date().getTime();
    console.log('milliseconds passed', end - start);
  }
});

在开始执行ajax之前保存时间值,然后在完成后再次执行。然后从另一个中减去一个,然后抽出时间。

save a time value before you start doing ajax stuff, and then do it again when it finishes. Then subtract one form the other and get your time.

这篇关于测量AJAX调用的处理时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆