build: add ng_benchmark macro to run perf benchmarks (#33389)

this makes running and profiling tests much easier. Example usage:

```
yarn bazel run --define=compile=aot //packages/core/test/render3/perf:noop_change_detection
```

See README.md update for more info.

PS: I considered moving the ng_rollup bundle into the macro but I didn't want to make
  too many changes in this PR. If we find running benchmarks in this way useful, we
  should refactor the build file more, and move the ng_rollup_bundle targets into the
  macro.

PR Close #33389
This commit is contained in:
Igor Minar
2019-10-24 17:40:17 -07:00
committed by Andrew Kushnir
parent 14c4b1b205
commit 4b81bb5c97
4 changed files with 111 additions and 17 deletions

View File

@ -71,8 +71,10 @@ The resulting output should look something like this:
### Notes
In all the above commands `${BENCHMARK}` should be replaced with the actual benchmark (folder) name, ex.:
- build: `yarn bazel build //packages/core/test/render3/perf:noop_change_detection.min_debug.es2015.js --define=compile=aot`
- run: `time node dist/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.es2015.js`
- profile: `node --no-turbo-inlining --inspect-brk dist/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.es2015.js profile`
- experimenting `BENCHMARK=noop_change_detection; yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.es2015.js --define=compile=aot && node dist/bin/packages/core/test/render3/perf/${BENCHMARK}.min_debug.es2015.js`
To run the benchmark use `bazel run <benchmark_target>`, example:
- `yarn bazel run --define=compile=aot //packages/core/test/render3/perf:noop_change_detection`
To profile, append `_profile` to the target name and attach a debugger via chrome://inspect, example:
- `yarn bazel run --define=compile=aot //packages/core/test/render3/perf:noop_change_detection_profile`
To interactively edit/rerun benchmarks use `ibazel` instead of `bazel`.