- 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.profileEnd() Method
The Node.js console.profileEnd() method will stop the JavaScript CPU profiling session of the profile which has been called previously and print the report to the profiles panel of the inspector. In simple terms, it stops the recording of a profile that was previously started with the console.profile() method.
Syntax
Following is the syntax of the Node.js console.profileEnd() method −
console.profileEnd([label])
Parameters
label − We can pass the label for the profile with a name and the input name should be a string. And this passed label should be the same as in the console.profile() method to close the particular profile.
Return value
This method returns nothing instead; it will end the JavaScript CPU profile in the inspector.
Example
In this example,
We are calling the Node.js console.profile() method by passing a name to the label parameter.
Then we have written some lines of code.
Then we are ending the previously called profile with the console.profileEnd() method with the same label in the console.profile() method.
console.profile("one"); var a = 5, b = 5; var c = a * b; console.log(c); console.profileEnd("one");
Output
25
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, the console.profileEnd() method has a profile name and it matches the name of the profile is started, then that profile will be stopped.
Example
In this example,
We are calling the Node.js console.profile() method by passing a name to the label parameter.
Then we are performing an operation for adding two numbers.
Then we are ending the previously called profile with the console.profileEnd() method with different label
console.profile("one"); var a = 5, b = 5; var c = a + b; console.log(c); console.profileEnd("two");
Output
10
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, the console.profileEnd() method has a profile name and it is not matching with name of the profile is started, so no changes will be made.
Example
In this example,
We are calling the Node.js console.profile() method with three times with different label names.
Then we are performing an operation for adding an element to the array.
Then we are ending the previously called profile with the console.profileEnd() method without passing any label of a profile being recorded.
console.profile("One"); console.profile("Two"); console.profile("Three"); var array = ["Blue", "Black", "Purple"]; array.push("Yellow"); console.log(array); console.profileEnd();
Output
[ 'Blue', 'Black', 'Purple', 'Yellow' ]
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 the figure below figure. The console.profileEnd() method is called without any passed profile name so, the most recently started profile will be stopped.
Example
In this example,
We are calling the Node.js console.profile() method without passing any name to the label parameter.
Then we have written some lines of code.
Then we are ending the previously called profile with the console.profileEnd() method.
console.profile(); for (var i = 0; i < 3; i++) { console.log(i); } console.profileEnd();
Output
0 1 2
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, if we do not pass any label to the method, by default, it will name the profile as 'Profile 1' and so on.
To Continue Learning Please Login
Login with Google