Skip to content

Commit 4d711a7

Browse files
committed
docs(@angular/cli): how to capture a CPU profile
Add documentation on how to generate a CPU profile capture.
1 parent 8bc91cf commit 4d711a7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/angular/cli/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,28 @@ Then you can add breakpoints in `dist/@angular` files.
226226

227227
For more informations about Node.js debugging in VS Code, see the related [VS Code Documentation](https://code.visualstudio.com/docs/nodejs/nodejs-debugging).
228228

229+
### CPU Profiling
230+
231+
In order to investigate performance issues, CPU profiling is often usefull.
232+
233+
To capture a CPU profiling, you can:
234+
1. install the v8-profiler-node8 dependency: `npm install v8-profiler-node8 --no-save`
235+
1. set the NG_CLI_PROFILING Environment variable to the file name you want:
236+
* on Unix systems (Linux & Mac OS X): ̀`export NG_CLI_PROFILING=my-profile`
237+
* on Windows: ̀̀`setx NG_CLI_PROFILING my-profile`
238+
239+
Then, just run the ng command on which you want to capture a CPU profile.
240+
You will then obtain a `my-profile.cpuprofile` file in the folder from wich you ran the ng command.
241+
242+
You can use the Chrome Devtools to process it. To do so:
243+
1. open `chrome://inspect/#devices` in Chrome
244+
1. click on "Open dedicated DevTools for Node"
245+
1. go to the "profiler" tab
246+
1. click on the "Load" button and select the generated .cpuprofile file
247+
1. on the left panel, select the associated file
248+
249+
In addition to this one, another, more elaborated way to capture a CPU profile using the Chrome Devtools is detailed in https://github.com/angular/angular-cli/issues/8259#issue-269908550.
250+
229251
## Documentation
230252

231253
The documentation for the Angular CLI is located in this repo's [wiki](https://github.com/angular/angular-cli/wiki).

0 commit comments

Comments
 (0)