javascript measure time elapsed code example
Example 1: Javascript measure function run time
var startTime = performance.now();
alert('Run some function here');
var endTime = performance.now();
var totalTime=endTime-startTime;
alert('Total time:'+totalTime +'ms');
Example 2: get elapsed time javascript date
var startTime, endTime;
function start() {
startTime = new Date();
};
function end() {
endTime = new Date();
var timeDiff = endTime - startTime;
timeDiff /= 1000;
var seconds = Math.round(timeDiff);
console.log(seconds + " seconds");
}