|
1 | 1 | # Advanced Performance profiling for Nx
|
2 | 2 |
|
3 |
| -| Default | Advanced | |
4 |
| -|----------------------------------------------------------|----------------------------------------------------------------------------| |
5 |
| -|  |  | |
| 3 | +| Default | Advanced | |
| 4 | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- | |
| 5 | +|  |  | |
6 | 6 | | `NX_DAEMON=false NX_PERF_LOGGING=true NX_CACHE=false nx show projects` | `node ./nx-advanced-profile.js --args=show,projects` |
|
7 | 7 |
|
| 8 | +Nx it boosting performance, yet when there is a question, it is not always easy to understand where the time is spent. |
| 9 | +By default, Nx provides a way to profile the performance of the CLI commands using `NX_PERF_LOGGING=true` and `NX_DAEMON=false`. |
| 10 | +This will create a minimal text log in the terminal. |
| 11 | + |
| 12 | +This script provides a way to profile the performance of the Nx CLI commands in high detail and in a great UI, the Chrome DevTools. |
| 13 | +It will create a flame graph that shows the time spent in each function and the call stack, including the ones from child processes |
| 14 | + |
8 | 15 | ## Main Process Logging
|
9 | 16 |
|
10 | 17 | 1. Copy the `tools` folder into your workspace root.
|
11 | 18 | 2. Run `node ./tools/nx-advanced-profile.bin.js`.
|
12 | 19 | The script will create a file named `.nx-profiling/nx-show-projects.<Date.now()>.profile.json`.
|
13 | 20 | 3. Open Chrome browser
|
14 |
| - 1. Open DevTools (F12) |
| 21 | + 1. Open DevTools |
15 | 22 | 2. Go to the `Performance` tab
|
16 |
| -4. Drag and drop the `<process>.profile.json` file into the DevTools window. |
| 23 | + 3. Drag and drop the `<process>.profile.json` file into the DevTools window. |
17 | 24 |
|
18 | 25 | 
|
19 | 26 |
|
|
22 | 29 | 1. Run `node ./tools/nx-advanced-profile.postinstall.js`. This modifies the Nx sourcecode to be patched. (Don't forget
|
23 | 30 | to revert your changes)
|
24 | 31 | 2. Run `node ./tools/nx-advanced-profile.bin.js --noPatch`. (As it is now patched inside the file directly)
|
25 |
| -3. Drag and drop the `<process>.profile.json` file into the DevTools window. |
| 32 | +3. Open DevTools |
26 | 33 |
|
27 | 34 | 
|
28 | 35 |
|
29 | 36 | ## Terminal Arguments
|
30 | 37 |
|
31 | 38 | | Option | Shorthand | Description |
|
32 |
| -|-------------|-----------|-----------------------------------------| |
| 39 | +| ----------- | --------- | --------------------------------------- | |
33 | 40 | | `--args` | | comma separated process args `-t,build` |
|
34 | 41 | | `--verbose` | `-v` | Show verbose output |
|
35 | 42 | | `--noPatch` | `-p` | Don't patch the Nx sourcecode |
|
|
41 | 48 | ```sh
|
42 | 49 | node ./tools/nx-advanced-profile.bin.js --verbose --noPatch --outDir=./tools/demo --outFile=nx-show-projects
|
43 | 50 | ```
|
44 |
| - |
|
0 commit comments