angular-cn/packages/core/test/render3/perf/BUILD.bazel

219 lines
4.1 KiB
Python
Raw Normal View History

package(default_visibility = ["//visibility:private"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_benchmark", "ng_rollup_bundle", "ts_library")
ts_library(
name = "perf_lib",
srcs = glob(
["**/*.ts"],
),
deps = [
"//packages/core",
refactor(ivy): Add style reconciliation algorithm (#34004) This change introduces class/style reconciliation algorithm for DOM elements. NOTE: The code is not yet hooked up, it will be used by future style algorithm. Background: Styling algorithm currently has [two paths](https://hackmd.io/@5zDGNGArSxiHhgvxRGrg-g/rycZk3N5S) when computing how the style should be rendered. 1. A direct path which concatenates styling and uses `elemnent.className`/`element.style.cssText` and 2. A merge path which uses internal data structures and uses `element.classList.add/remove`/`element.style[property]`. The situation is confusing and hard to follow/maintain. So a future PR will remove the merge-path and do everything with direct-path. This however breaks when some other code adds class or style to the element without Angular's knowledge. If this happens instead of switching from direct-path to merge-path algorithm, this change provides a different mental model whereby we always do `direct-path` but the code which writes to the DOM detects the situation and reconciles the out of bound write. The reconciliation process is as follows: 1. Detect that no one has modified `className`/`cssText` and if so just write directly (fast path). 2. If out of bounds write did occur, switch from writing using `className`/`cssText` to `element.classList.add/remove`/`element.style[property]`. This does require that the write function computes the difference between the previous Angular expected state and current Angular state. (This requires a parser. The advantage of having a parser is that we can support `style="width: {{exp}}px" kind of bindings.`) Compute the diff and apply it in non destructive way using `element.classList.add/remove`/`element.style[property]` Properties of approach: - If no out of bounds style modification: - Very fast code path: Just concatenate string in right order and write them to DOM. - Class list order is preserved - If out of bounds style modification detected: - Penalty for parsing - Switch to non destructive modification: `element.classList.add/remove`/`element.style[property]` - Switch to alphabetical way of setting classes. PR Close #34004
2019-11-22 23:40:29 -05:00
"//packages/core/src/util",
"@npm//@types/jasmine",
"@npm//@types/node",
],
)
jasmine_node_test(
name = "perf",
deps = [
":perf_lib",
],
)
ng_rollup_bundle(
name = "class_binding_lib",
entry_point = ":class_binding/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "class_binding",
bundle = ":class_binding_lib",
)
ng_rollup_bundle(
name = "directive_inputs_lib",
entry_point = ":directive_inputs/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "directive_inputs",
bundle = ":directive_inputs_lib",
)
ng_rollup_bundle(
name = "directive_instantiate_lib",
entry_point = ":directive_instantiate/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "directive_instantiate",
bundle = ":directive_instantiate_lib",
)
ng_rollup_bundle(
name = "element_text_create_lib",
entry_point = ":element_text_create/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "element_text_create",
bundle = ":element_text_create_lib",
)
ng_rollup_bundle(
name = "interpolation_lib",
entry_point = ":interpolation/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "interpolation",
bundle = ":interpolation_lib",
)
ng_rollup_bundle(
name = "listeners_lib",
entry_point = ":listeners/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "listeners",
bundle = ":listeners_lib",
)
ng_rollup_bundle(
name = "noop_change_detection_lib",
entry_point = ":noop_change_detection/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "noop_change_detection",
bundle = ":noop_change_detection_lib",
)
ng_rollup_bundle(
name = "ng_template_lib",
entry_point = ":ng_template/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "ng_template",
bundle = ":ng_template_lib",
)
ng_rollup_bundle(
name = "property_binding_lib",
entry_point = ":property_binding/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "property_binding",
bundle = ":property_binding_lib",
)
ng_rollup_bundle(
name = "property_binding_update_lib",
entry_point = ":property_binding_update/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "property_binding_update",
bundle = ":property_binding_update_lib",
)
ng_rollup_bundle(
name = "style_binding_lib",
entry_point = ":style_binding/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "style_binding",
bundle = ":style_binding_lib",
)
ng_rollup_bundle(
name = "style_and_class_bindings_lib",
entry_point = ":style_and_class_bindings/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "style_and_class_bindings",
bundle = ":style_and_class_bindings_lib",
)
ng_rollup_bundle(
name = "map_based_style_and_class_bindings_lib",
entry_point = ":map_based_style_and_class_bindings/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "map_based_style_and_class_bindings",
bundle = ":map_based_style_and_class_bindings_lib",
)
ng_rollup_bundle(
name = "duplicate_style_and_class_bindings_lib",
entry_point = ":duplicate_style_and_class_bindings/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "duplicate_style_and_class_bindings",
bundle = ":duplicate_style_and_class_bindings_lib",
)
ng_rollup_bundle(
name = "duplicate_map_based_style_and_class_bindings_lib",
entry_point = ":duplicate_map_based_style_and_class_bindings/index.ts",
deps = [
":perf_lib",
],
)
ng_benchmark(
name = "duplicate_map_based_style_and_class_bindings",
bundle = ":duplicate_map_based_style_and_class_bindings_lib",
)