Skip to content

Commit 1bbf39d

Browse files
committed
update docs
1 parent d546ec7 commit 1bbf39d

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
# Advanced Performance profiling for Nx
22

3-
| Default | Advanced |
4-
|----------------------------------------------------------|----------------------------------------------------------------------------|
5-
| ![flame-charts.png](./tools/imgs/nx-default-profile.png) | ![flame-charts.png](./tools/imgs/main-and-forked-process-flame-charts.png) |
3+
| Default | Advanced |
4+
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- |
5+
| ![flame-charts.png](./tools/imgs/nx-default-profile.png) | ![flame-charts.png](./tools/imgs/main-and-forked-process-flame-charts.png) |
66
| `NX_DAEMON=false NX_PERF_LOGGING=true NX_CACHE=false nx show projects` | `node ./nx-advanced-profile.js --args=show,projects` |
77

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+
815
## Main Process Logging
916

1017
1. Copy the `tools` folder into your workspace root.
1118
2. Run `node ./tools/nx-advanced-profile.bin.js`.
1219
The script will create a file named `.nx-profiling/nx-show-projects.<Date.now()>.profile.json`.
1320
3. Open Chrome browser
14-
1. Open DevTools (F12)
21+
1. Open DevTools
1522
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.
1724

1825
![flame-charts.png](./tools/imgs/main-process-flame-charts.png)
1926

@@ -22,14 +29,14 @@
2229
1. Run `node ./tools/nx-advanced-profile.postinstall.js`. This modifies the Nx sourcecode to be patched. (Don't forget
2330
to revert your changes)
2431
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
2633

2734
![flame-charts.png](./tools/imgs/main-and-forked-process-flame-charts.png)
2835

2936
## Terminal Arguments
3037

3138
| Option | Shorthand | Description |
32-
|-------------|-----------|-----------------------------------------|
39+
| ----------- | --------- | --------------------------------------- |
3340
| `--args` | | comma separated process args `-t,build` |
3441
| `--verbose` | `-v` | Show verbose output |
3542
| `--noPatch` | `-p` | Don't patch the Nx sourcecode |
@@ -41,4 +48,3 @@
4148
```sh
4249
node ./tools/nx-advanced-profile.bin.js --verbose --noPatch --outDir=./tools/demo --outFile=nx-show-projects
4350
```
44-

nx.json

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"$schema": "./node_modules/nx/schemas/nx-schema.json",
33
"namedInputs": {
4-
"default": [
5-
"{projectRoot}/**/*",
6-
"sharedGlobals"
7-
],
4+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
85
"production": [
96
"default",
107
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
@@ -15,9 +12,7 @@
1512
"!{projectRoot}/jest.config.[jt]s",
1613
"!{projectRoot}/test-setup.[jt]s"
1714
],
18-
"sharedGlobals": [
19-
"{workspaceRoot}/.github/workflows/ci.yml"
20-
]
15+
"sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"]
2116
},
2217
"nxCloudId": "67f4ed637b16f351e65d5530",
2318
"plugins": [
@@ -60,9 +55,7 @@
6055
"options": {
6156
"targetName": "test"
6257
},
63-
"exclude": [
64-
"packages/app-0-e2e/**/*"
65-
]
58+
"exclude": ["packages/app-0-e2e/**/*"]
6659
},
6760
{
6861
"plugin": "@nx/rollup/plugin",
@@ -85,29 +78,17 @@
8578
],
8679
"targetDefaults": {
8780
"test": {
88-
"dependsOn": [
89-
"^build"
90-
]
81+
"dependsOn": ["^build"]
9182
},
9283
"@nx/esbuild:esbuild": {
9384
"cache": true,
94-
"dependsOn": [
95-
"^build"
96-
],
97-
"inputs": [
98-
"production",
99-
"^production"
100-
]
85+
"dependsOn": ["^build"],
86+
"inputs": ["production", "^production"]
10187
},
10288
"@nx/js:swc": {
10389
"cache": true,
104-
"dependsOn": [
105-
"^build"
106-
],
107-
"inputs": [
108-
"production",
109-
"^production"
110-
]
90+
"dependsOn": ["^build"],
91+
"inputs": ["production", "^production"]
11192
}
11293
}
11394
}

0 commit comments

Comments
 (0)