Node.js console.timeLog() Method
The console.timeLog() method is an inbuilt function in Nodejs that is used to display the time for each execution. This function is proved to be effective when used in a loop.
Syntax:
console.log([label][, ...data])
Parameters: This function accepts two or more parameters.
Return Value: This method displays the time for the execution.
Below examples illustrate the console.timeLog() method in Node.js:
Example 1:
console.time( "executionTime" );
for (let i = 0; i < 10; i++) {
console.timeLog( "executionTime" );
}
|
Output:
Example 2:
console.time( "totalExecutionTime" );
console.time( "executionTime" );
for (let i = 0; i < 10; i++) {
console.timeLog( "executionTime" );
}
console.timeLog( "totalExecutionTime" );
|
Output:
Reference: https://nodejs.org/api/console.html#console_console_timelog_label_data
Last Updated :
07 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...