Script Console time

Console time

by dadviegas

JavaScript

console.time('profile'); 
 
for ( var i=0; i < 100000; i++) { 
   var arr = new Array(); 
} 
 
var a = console.timeEnd('profile'); 


alert(a);


function timewatch()
{
   console.time('timewatch'); 
   var b = console.timeEnd('timewatch');
   alert(b); 
}

timewatch();


var one=new Date();
for ( var i=0; i < 100000; i++) {
   var arr = new Array();
} 
var two=new Date();



//Calculate difference btw the two dates, and convert to days
alert(two.getMilliseconds()-one.getMilliseconds());