- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
NodeJS - console.timeStamp() Method
The Node.js console.timeStamp() method is used to add a timestamp entry in the Browser's performance timeline.
This can be helpful for tracking and measuring the execution time of code snippets or functions by creating a marker that can later be referenced within the browser's performance timeline. It takes an optional label parameter which will appear along with the timestamp value in the performance timeline.
The Node.js console.timeStamp() method does not display anything in the output unless we use it in the inspector and this method is added in the Node.js version of v8.0.0. This will add an event with or without the label to the timeline panel of the inspector tab. Now let's look into the syntax and usage of the console.timeStamp() method of Node.js.
Syntax
Following is the syntax of the Node.js console.timeStamp() method −
console.timeStamp( [label] );
Parameters
label − We can pass the label for the method with a name and the input name should be a string.
Return value
This method doesn't return anything instead; it prints the timestamp at every call in the inspector element of the browser.
Example
In this example,
We are calling the Node.js console.profile() method by passing a name to the label parameter.
Then we are calling the console.timeStamp() method with the same label name as the profile we have started.
Then we are ending the profile with the console.profileEnd() method.
console.profile('one'); console.log('Welcome to %s', 'Tutorialspoint'); console.timeStamp('one'); console.log('Simply Easy %s at your fingertips', 'Learning'); console.profileEnd('one');
Output
Welcome to Tutorialspoint Simply Easy Learning at your fingertips
To understand better, execute the above code in the browser's console. Following is the output, if we execute it in the browser's console.
As we can see from the figure below, the profile has started and ended but the timeStamp is not visible. The console.timeStamp() method will add an event with the passed label name to the timeline panel of the inspector element.
Example
In this example,
We are calling the Node.js console.profile() method with a name the label parameter.
Then we are calling the console.timeStamp() inside the for loop with the same label name as the profile we have started.
Then we are ending the profile with the console.profileEnd() method.
console.profile('Two'); for (var i = 0; i<=3; i++) { console.timeStamp('Two'); } console.profileEnd('Two');
Output
//Returns nothing
To understand better, execute the above code in the browser's console. Following is the output, if we execute it in the browser's console.
As we can see in the figure below. So, it will add three events with the passed label name to the timeline panel of the inspector.
To Continue Learning Please Login
Login with Google