angular-cn/packages/core/test/render3/perf/README.md

72 lines
3.9 KiB
Markdown
Raw Normal View History

### Build
```
refactor(core): tweek micro-benchmarks to make them more consistent (#33207) ``` ┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐ │ (index) │ time │ unit │ base_time │ base_unit │ % │ ├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤ │ directive_instantiate │ 2.474 │ 'us' │ 2.507 │ 'us' │ -1.32 │ │ element_text_create │ 1.313 │ 'us' │ 1.319 │ 'us' │ -0.45 │ │ interpolation │ 220.17 │ 'us' │ 224.217 │ 'us' │ -1.8 │ │ listeners │ 1.988 │ 'us' │ 2.021 │ 'us' │ -1.63 │ │ map_based_style_and_class_bindings │ 17.908 │ 'ms' │ 18.523 │ 'ms' │ -3.32 │ │ noop_change_detection │ 24.851 │ 'us' │ 24.874 │ 'us' │ -0.09 │ │ property_binding │ 218.76 │ 'us' │ 216.736 │ 'us' │ 0.93 │ │ property_binding_update │ 443.175 │ 'us' │ 447.686 │ 'us' │ -1.01 │ │ style_and_class_bindings │ 1.053 │ 'ms' │ 1.069 │ 'ms' │ -1.5 │ │ style_binding │ 488.154 │ 'us' │ 484.092 │ 'us' │ 0.84 │ └────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘ ``` PR Close #33207
2019-10-16 16:37:00 -04:00
yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.es2015.js --define=compile=aot
```
### Run
```
refactor(core): tweek micro-benchmarks to make them more consistent (#33207) ``` ┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐ │ (index) │ time │ unit │ base_time │ base_unit │ % │ ├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤ │ directive_instantiate │ 2.474 │ 'us' │ 2.507 │ 'us' │ -1.32 │ │ element_text_create │ 1.313 │ 'us' │ 1.319 │ 'us' │ -0.45 │ │ interpolation │ 220.17 │ 'us' │ 224.217 │ 'us' │ -1.8 │ │ listeners │ 1.988 │ 'us' │ 2.021 │ 'us' │ -1.63 │ │ map_based_style_and_class_bindings │ 17.908 │ 'ms' │ 18.523 │ 'ms' │ -3.32 │ │ noop_change_detection │ 24.851 │ 'us' │ 24.874 │ 'us' │ -0.09 │ │ property_binding │ 218.76 │ 'us' │ 216.736 │ 'us' │ 0.93 │ │ property_binding_update │ 443.175 │ 'us' │ 447.686 │ 'us' │ -1.01 │ │ style_and_class_bindings │ 1.053 │ 'ms' │ 1.069 │ 'ms' │ -1.5 │ │ style_binding │ 488.154 │ 'us' │ 484.092 │ 'us' │ 0.84 │ └────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘ ``` PR Close #33207
2019-10-16 16:37:00 -04:00
node dist/bin/packages/core/test/render3/perf/${BENCHMARK}.min_debug.es2015.js
```
### Profile
```
refactor(core): tweek micro-benchmarks to make them more consistent (#33207) ``` ┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐ │ (index) │ time │ unit │ base_time │ base_unit │ % │ ├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤ │ directive_instantiate │ 2.474 │ 'us' │ 2.507 │ 'us' │ -1.32 │ │ element_text_create │ 1.313 │ 'us' │ 1.319 │ 'us' │ -0.45 │ │ interpolation │ 220.17 │ 'us' │ 224.217 │ 'us' │ -1.8 │ │ listeners │ 1.988 │ 'us' │ 2.021 │ 'us' │ -1.63 │ │ map_based_style_and_class_bindings │ 17.908 │ 'ms' │ 18.523 │ 'ms' │ -3.32 │ │ noop_change_detection │ 24.851 │ 'us' │ 24.874 │ 'us' │ -0.09 │ │ property_binding │ 218.76 │ 'us' │ 216.736 │ 'us' │ 0.93 │ │ property_binding_update │ 443.175 │ 'us' │ 447.686 │ 'us' │ -1.01 │ │ style_and_class_bindings │ 1.053 │ 'ms' │ 1.069 │ 'ms' │ -1.5 │ │ style_binding │ 488.154 │ 'us' │ 484.092 │ 'us' │ 0.84 │ └────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘ ``` PR Close #33207
2019-10-16 16:37:00 -04:00
node --no-turbo-inlining --inspect-brk dist/bin/packages/core/test/render3/perf/${BENCHMARK}.min_debug.es2015.js
```
then connect with a debugger (the `--inspect-brk` option will make sure that benchmark execution doesn't start until a debugger is connected and the code execution is manually resumed).
The actual benchmark code has calls that will start (`console.profile`) and stop (`console.profileEnd`) a profiling session.
### Run All
To run all of the benchmarks use the `profile_all.js` script:
```
node packages/core/test/render3/perf/profile_all.js
```
NOTE: This command will build all of the tests, so there is no need to do so manually.
Optionally use the `--write` command to save the run result to a file for later comparison.
```
node packages/core/test/render3/perf/profile_all.js --write baseline.json
```
### Comparing Runs
If you have saved the baseline (as described in the step above) you can use it to get change in performance like so:
```
node packages/core/test/render3/perf/profile_all.js --read baseline.json
```
The resulting output should look something like this:
```
┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐
│ (index) │ time │ unit │ base_time │ base_unit │ % │
├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤
│ directive_instantiate │ 276.652 │ 'ms' │ 286.292 │ 'ms' │ -3.37 │
│ element_text_create │ 262.868 │ 'ms' │ 260.031 │ 'ms' │ 1.09 │
│ interpolation │ 257.733 │ 'us' │ 260.489 │ 'us' │ -1.06 │
│ listeners │ 1.997 │ 'us' │ 1.985 │ 'us' │ 0.6 │
│ map_based_style_and_class_bindings │ 10.07 │ 'ms' │ 9.786 │ 'ms' │ 2.9 │
│ noop_change_detection │ 93.256 │ 'us' │ 91.745 │ 'us' │ 1.65 │
│ property_binding │ 290.777 │ 'us' │ 280.586 │ 'us' │ 3.63 │
│ property_binding_update │ 588.545 │ 'us' │ 583.334 │ 'us' │ 0.89 │
│ style_and_class_bindings │ 1.061 │ 'ms' │ 1.047 │ 'ms' │ 1.34 │
│ style_binding │ 543.841 │ 'us' │ 545.385 │ 'us' │ -0.28 │
└────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘
```
### Notes
refactor(core): tweek micro-benchmarks to make them more consistent (#33207) ``` ┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐ │ (index) │ time │ unit │ base_time │ base_unit │ % │ ├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤ │ directive_instantiate │ 2.474 │ 'us' │ 2.507 │ 'us' │ -1.32 │ │ element_text_create │ 1.313 │ 'us' │ 1.319 │ 'us' │ -0.45 │ │ interpolation │ 220.17 │ 'us' │ 224.217 │ 'us' │ -1.8 │ │ listeners │ 1.988 │ 'us' │ 2.021 │ 'us' │ -1.63 │ │ map_based_style_and_class_bindings │ 17.908 │ 'ms' │ 18.523 │ 'ms' │ -3.32 │ │ noop_change_detection │ 24.851 │ 'us' │ 24.874 │ 'us' │ -0.09 │ │ property_binding │ 218.76 │ 'us' │ 216.736 │ 'us' │ 0.93 │ │ property_binding_update │ 443.175 │ 'us' │ 447.686 │ 'us' │ -1.01 │ │ style_and_class_bindings │ 1.053 │ 'ms' │ 1.069 │ 'ms' │ -1.5 │ │ style_binding │ 488.154 │ 'us' │ 484.092 │ 'us' │ 0.84 │ └────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘ ``` PR Close #33207
2019-10-16 16:37:00 -04:00
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`
refactor(core): tweek micro-benchmarks to make them more consistent (#33207) ``` ┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐ │ (index) │ time │ unit │ base_time │ base_unit │ % │ ├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤ │ directive_instantiate │ 2.474 │ 'us' │ 2.507 │ 'us' │ -1.32 │ │ element_text_create │ 1.313 │ 'us' │ 1.319 │ 'us' │ -0.45 │ │ interpolation │ 220.17 │ 'us' │ 224.217 │ 'us' │ -1.8 │ │ listeners │ 1.988 │ 'us' │ 2.021 │ 'us' │ -1.63 │ │ map_based_style_and_class_bindings │ 17.908 │ 'ms' │ 18.523 │ 'ms' │ -3.32 │ │ noop_change_detection │ 24.851 │ 'us' │ 24.874 │ 'us' │ -0.09 │ │ property_binding │ 218.76 │ 'us' │ 216.736 │ 'us' │ 0.93 │ │ property_binding_update │ 443.175 │ 'us' │ 447.686 │ 'us' │ -1.01 │ │ style_and_class_bindings │ 1.053 │ 'ms' │ 1.069 │ 'ms' │ -1.5 │ │ style_binding │ 488.154 │ 'us' │ 484.092 │ 'us' │ 0.84 │ └────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘ ``` PR Close #33207
2019-10-16 16:37:00 -04:00
- 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`