angular-cn/packages/core/test/render3/perf
Miško Hevery d3f3d9b4cb test: Add script which allows running all of the profiling tests and compare results (#33186)
PR Close #33186
2019-10-16 10:22:30 -04:00
..
directive_instantiate test: Add script which allows running all of the profiling tests and compare results (#33186) 2019-10-16 10:22:30 -04:00
element_text_create build: fix compilation error in benchmark (#33067) 2019-10-09 13:40:10 -07:00
interpolation perf(ivy): convert all node-based benchmark to use a testing harness (#32699) 2019-09-16 09:31:15 -07:00
listeners perf(ivy): move attributes array into component def (#32798) 2019-10-09 13:16:55 -07:00
map_based_style_and_class_bindings refactor(ivy): move `styling/instructions.ts` to `instructions/styling.ts` (#32731) 2019-09-18 15:06:39 -07:00
noop_change_detection perf(ivy): convert all node-based benchmark to use a testing harness (#32699) 2019-09-16 09:31:15 -07:00
property_binding perf(ivy): convert all node-based benchmark to use a testing harness (#32699) 2019-09-16 09:31:15 -07:00
property_binding_update refactor(ivy): improve micro-benchmark profiling (#32647) 2019-09-12 13:06:38 -07:00
style_and_class_bindings perf(ivy): move attributes array into component def (#32798) 2019-10-09 13:16:55 -07:00
style_binding refactor(ivy): move `styling/instructions.ts` to `instructions/styling.ts` (#32731) 2019-09-18 15:06:39 -07:00
BUILD.bazel perf(ivy): introduce micro-benchmark for directive instantiation (#33082) 2019-10-10 13:56:52 -07:00
README.md test: Add script which allows running all of the profiling tests and compare results (#33186) 2019-10-16 10:22:30 -04:00
micro_bench.ts test: Add script which allows running all of the profiling tests and compare results (#33186) 2019-10-16 10:22:30 -04:00
noop_renderer.ts perf(ivy): add static attributes to the element_text_create benchmark (#32997) 2019-10-08 13:02:11 -07:00
profile_all.js test: Add script which allows running all of the profiling tests and compare results (#33186) 2019-10-16 10:22:30 -04:00
setup.ts perf(ivy): move attributes array into component def (#32798) 2019-10-09 13:16:55 -07:00

README.md

Build

yarn bazel build //packages/core/test/render3/perf:{name}.min_debug.es2015.js --define=compile=aot

Run

node dist/bin/packages/core/test/render3/perf/{name}.min_debug.es2015.js

Profile

node --no-turbo-inlining --inspect-brk dist/bin/packages/core/test/render3/perf/{name}.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

In all the above commands {name} 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