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?
The easiest way to track execution time is to use a date object. Using Date. now() that returns the total number of milliseconds elapsed since the Unix epoch, we can store the value before and after the execution of the function to be measured and then get the difference of the two.
count() The console. count() method logs the number of times that this particular call to count() has been called.
Infinitely. Not really until you don't overflow the stack with function calls. Since each time a function is called all the variables used need space to be store in stack and stack is of limited size so someway in middle of any hundredth or thousandth call you will run out stack for function call.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With