javascript how to get time taken bya function code example
Example 1: time taken for a function javascript
console.time("timer"); //start time with name = timer
console.timeEnd("timer"); //end timer and log time difference
Example 2: Javascript measure function run time
var startTime = performance.now();
alert('Run some function here');
var endTime = performance.now();
var totalTime=endTime-startTime;// time took to run in milliseconds
alert('Total time:'+totalTime +'ms');