console.time & console.timeEnd
console.time starts the time and
console.timeEnd stops the timer and spits out the duration:
// Kick off the timer console.time('testForEach'); // (Do some testing of a forEach, for example) // End the timer, get the elapsed time console.timeEnd('testForEach'); // 4522.303ms (or whatever time elapsed)
Passing a timer name as the first argument allows you to manage concurrent timers. The
console.timeEnd call immediately spits out the elapsed time in milliseconds.
There are more advanced techniques for performance testing and benchmarking but
timeEnd provide a quick manual method for speed testing!