I am doing some JavaScript exercise and thinking about ways to improve my solution(algorithm) to the exercise. I am thinking of calculating runtime speed after tweaking the code so I will know how much the speed is improved. I searched and found this method and think I can do the same. Here is what I did,
var d = new Date();
var startTime = d.getTime();
var endTime;
function testTargeAlgorithm(){
....
....
}
testTargetAlgorithm();
endTime = d.getTime();
console.log(endTime-startTime);
It's a very simple algorithm so I don't expect there will be notable difference between the time. But if millisecond cannot measure the speed improvement, what else can I do?