JavaScript timing

So you quickly want to know how long a piece JavaScript takes to execute? And you want to know it now? Here's a simple way to do it. You will get a popup with the amount of milliseconds your piece of code took.

var start = new Date().getTime();
// Your blazingly fast JaveScript code goes here
alert(new Date().getTime() - start);

Remember that everything else your computer is doing (in and outside of the browser) will influence this. Keep that in mind and don't focus on every millisecond change between runs.

Geen opmerkingen:

Een reactie posten