get execution time in javascript
snippet in javascript

time taken for a function javascript


console.time("timer");   //start time with name = timer
console.timeEnd("timer"); //end timer and log time difference

Javascript measure function run time


var startTime =;

alert('Run some function here');

var endTime =;
var totalTime=endTime-startTime;// time took to run in milliseconds

alert('Total time:'+totalTime +'ms');

get execution time in javascript


var t0 =

doSomething()   // <---- The function you're measuring time for 

var t1 =
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")