Tuesday 2 October 2018

node.js: console.timeEnd([label]): Stops a timer

console.timeEnd([label])
Stops a timer that was previously started by calling console.time() and prints the result to stdout.

HelloWorld.js
/* Start the timer */
console.time('100000-elements');

for (let i = 0; i < 100000; i++) {

}

/* End the timer */
console.timeEnd('100000-elements');


Output
100000-elements: 3.242ms

Points to note
a.   Elapsed time is printed in milliseconds.
b.   Timers are identified by a unique label. In our example, '100000-elements' is the label.



Previous                                                 Next                                                 Home

No comments:

Post a Comment