Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('AppController', () => {
describe('getData', () => {
it('should return "Hello API"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({message: 'Hello API'});
expect(appController.getData()).toEqual({ message: 'Hello API' });
});
});
});
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('AppService', () => {

describe('getData', () => {
it('should return "Hello API"', () => {
expect(service.getData()).toEqual({message: 'Hello API'});
expect(service.getData()).toEqual({ message: 'Hello API' });
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getData(): { message: string } {
return ({ message: 'Hello API' });
return { message: 'Hello API' };
}
}
File renamed without changes.
4 changes: 3 additions & 1 deletion packages/app-1/src/main.ts → dummy/app-1/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ async function bootstrap() {
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
);
}

bootstrap();
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"types": [
"node"
],
"types": ["node"],
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "es2021"
},
"include": [
"src/**/*.ts"
],
"include": ["src/**/*.ts"],
"exclude": []
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ module.exports = {
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ["./src/assets"],
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
generatePackageJson: true,
})
}),
],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions packages/nx-perf/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"jsc": {
"target": "es2017",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"keepClassNames": true,
"externalHelpers": true,
"loose": true
},
"module": {
"type": "es6"
},
"sourceMaps": true,
"exclude": [
"jest.config.ts",
".*\\.spec.tsx?$",
".*\\.test.tsx?$",
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
".*.js$"
]
}
52 changes: 52 additions & 0 deletions packages/nx-perf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Advanced Performance Profiling for Nx

| Default | Advanced |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| ![flame-charts.png](./docs/imgs/nx-default-profile.png) | ![flame-charts.png](./tools/imgs/main-and-forked-process-flame-charts.png) |
| `NX_DAEMON=false NX_PERF_LOGGING=true NX_CACHE=false nx show projects` | `node ./profile.ts --args=show,projects` |

Nx it boosting performance, yet when there is a question, it is not always easy to understand where the time is spent.
By default, Nx provides a way to profile the performance of the CLI commands using `NX_PERF_LOGGING=true` and `NX_DAEMON=false`.
This will create a minimal text log in the terminal.

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.
It will create a flame graph that shows the time spent in each function and the call stack, including the ones from child processes

## Main Process Logging

1. Copy the `tools` folder into your workspace root.
2. Run `node ./tools/bin.ts`.
The script will create a file named `.nx-profiling/nx-show-projects.<Date.now()>.profile.json`.
3. Open Chrome browser
1. Open DevTools
2. Go to the `Performance` tab
3. Drag and drop the `<process>.profile.json` file into the DevTools window.

![flame-charts.png](./docs/imgs/main-process-flame-charts.png)

## Main and Forked Process Logging

1. Run `node ./tools/postinstall.ts`. This modifies the Nx sourcecode to be patched. (Don't forget
to revert your changes)
2. Run `node ./tools/bin.ts --noPatch`. (As it is now patched inside the file directly)
3. Open DevTools

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

## Terminal Arguments

| Option | Shorthand | Description |
| ----------- | --------- | ----------------------------------------- |
| `--args` | | comma separated process `--args=-t,build` |
| `--verbose` | `-v` | Show verbose output |
| `--noPatch` | `-p` | Don't patch the Nx sourcecode |
| `--outDir` | `-d` | Output directory |
| `--outFile` | `-f` | Output file |

**Example**

```sh
node ./tools/bin.ts --args=show,projects
node ./tools/bin.ts --args=show,projects --verbose
node ./tools/bin.ts -v -p -o./tools/demo -f=nx-show-projects.json
```
Loading
Loading