Answers for "js measure time"

4

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');
Posted by: Guest on July-25-2019
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);
Posted by: Guest on May-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language