Tuesday, 2 October 2018

node.js: console.timeLog([label][, ...data]): Print the elapsed time

console.timeLog([label][, ...data])
For a timer that was previously started by calling console.time(), it prints the elapsed time and other data arguments to stdout.

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

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

}

console.timeLog('100000-elements', "taken to iterate 100000 elements");

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

}

console.timeLog('100000-elements', "taken to iterate 100000 elements");

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


Output
100000-elements: 3.924ms taken to iterate 100000 elements
100000-elements: 11.753ms taken to iterate 100000 elements
100000-elements: 12.745ms



Previous                                                 Next                                                 Home

No comments:

Post a Comment