time a function js code example
Example 1: timeout javascript
setTimeout(function(){
//code goes here
}, 2000); //Time before execution
Example 2: javascript count time
var start = new Date().getTime();
for (i = 0; i < 50000; ++i) {
// do something
}
var end = new Date().getTime();
var time = end - start;
alert('Execution time: ' + time);