Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  182] [ 4]  / answers: 1 / hits: 24461  / 13 Years ago, tue, september 6, 2011, 12:00:00

I have jQuery functions; e.g A(), B() and C()
Each function makes some Ajax calls to different sites.



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?


More From » jquery

 Answers
155

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);
}

[#90248] Sunday, September 4, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
monetm

Total Points: 615
Total Questions: 103
Total Answers: 119

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
monetm questions
Fri, Feb 26, 21, 00:00, 3 Years ago
Wed, Sep 9, 20, 00:00, 4 Years ago
Sun, Jul 26, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;