我jQuery的功能;例如A(),B()和C() 每个功能使得一些Ajax调用不同的网站。
I have jQuery functions; e.g A(), B() and C() Each function makes some Ajax calls to different sites.
我要计算多少时间才能运行的每个功能(我猜毫秒) 我只是想测试我的code在长期循环和不同的现代浏览器(Safari /铬/ IE10 / Mozilla的)。 更具体地讲,我要计算多少时间才能通过各个Ajax请求的回调(这也是该函数结束正确的时间?) 我怎么可能做到这一点?
I want to calculate how much time it takes to run each function (I guess in milliseconds) I just want to test my code in long loops and in different modern browsers (Safari/Chrome/IE10/Mozilla). More specifically, I want to calculate how much time it takes to take a callback from each Ajax request (this is also the time that the function ends right?) How might I achieve this?
您可以从日期对象获得以毫秒为单位的时间。
You could get the time in milliseconds from the date object.
var start = new Date().getTime();
A();
function AJAXSuccessFunction() {
console.log(new Date().getTime() - start);
}
上一篇:如何做jQuery的跨域AJAX由于数据类型“文本”?如何做、数据类型、文本、AJAX
下一篇:CakePHP的 - 如何从控制器动作返回字符串(如JSON)到Ajax请求字符串、控制器、动作、CakePHP