From f41c41fd505f4306dacc68ed88acfe734b68cb9b Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Mon, 12 Aug 2019 12:47:26 +0200 Subject: [PATCH] test(ivy): add property binding node-based micro benchmark (#32104) PR Close #32104 --- packages/core/test/render3/perf/BUILD.bazel | 8 +++ .../core/test/render3/perf/noop_renderer.ts | 4 +- .../render3/perf/property_binding/index.ts | 71 +++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 packages/core/test/render3/perf/property_binding/index.ts diff --git a/packages/core/test/render3/perf/BUILD.bazel b/packages/core/test/render3/perf/BUILD.bazel index a7d7f6d4ee..109ddc3614 100644 --- a/packages/core/test/render3/perf/BUILD.bazel +++ b/packages/core/test/render3/perf/BUILD.bazel @@ -26,4 +26,12 @@ ng_rollup_bundle( deps = [ ":perf_lib", ], +) + +ng_rollup_bundle( + name = "property_binding", + entry_point = ":property_binding/index.ts", + deps = [ + ":perf_lib", + ], ) \ No newline at end of file diff --git a/packages/core/test/render3/perf/noop_renderer.ts b/packages/core/test/render3/perf/noop_renderer.ts index 98473d44c9..8c95b007ec 100644 --- a/packages/core/test/render3/perf/noop_renderer.ts +++ b/packages/core/test/render3/perf/noop_renderer.ts @@ -38,9 +38,7 @@ export class NoopRenderer implements ProceduralRenderer3 { removeStyle(el: RElement, style: string, flags?: RendererStyleFlags3|undefined): void { throw new Error('Method not implemented.'); } - setProperty(el: RElement, name: string, value: any): void { - throw new Error('Method not implemented.'); - } + setProperty(el: RElement, name: string, value: any): void { (el as any)[name] = value; } setValue(node: RComment|RText, value: string): void { node.textContent = value; } listen( target: RNode|'document'|'window'|'body', eventName: string, diff --git a/packages/core/test/render3/perf/property_binding/index.ts b/packages/core/test/render3/perf/property_binding/index.ts new file mode 100644 index 0000000000..3926372013 --- /dev/null +++ b/packages/core/test/render3/perf/property_binding/index.ts @@ -0,0 +1,71 @@ +import {ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element'; +import {ɵɵproperty} from '../../../../src/render3/instructions/property'; +import {ɵɵselect} from '../../../../src/render3/instructions/select'; +import {refreshView} from '../../../../src/render3/instructions/shared'; +import {RenderFlags} from '../../../../src/render3/interfaces/definition'; +import {TVIEW} from '../../../../src/render3/interfaces/view'; +import {setupRootViewWithEmbeddedViews} from '../setup'; + +`
+ + + + + + + + + + +
+`; +function TestInterpolationComponent_ng_template_0_Template(rf: RenderFlags, ctx: any) { + if (rf & 1) { + ɵɵelementStart(0, 'div'); + ɵɵelement(1, 'button'); + ɵɵelement(2, 'button'); + ɵɵelement(3, 'button'); + ɵɵelement(4, 'button'); + ɵɵelement(5, 'button'); + ɵɵelement(6, 'button'); + ɵɵelement(7, 'button'); + ɵɵelement(8, 'button'); + ɵɵelement(9, 'button'); + ɵɵelement(10, 'button'); + ɵɵelementEnd(); + } + if (rf & 2) { + ɵɵselect(1); + ɵɵproperty('title', 'title1'); + ɵɵselect(2); + ɵɵproperty('title', 'title2'); + ɵɵselect(3); + ɵɵproperty('title', 'title3'); + ɵɵselect(4); + ɵɵproperty('title', 'title4'); + ɵɵselect(5); + ɵɵproperty('title', 'title5'); + ɵɵselect(6); + ɵɵproperty('title', 'title6'); + ɵɵselect(7); + ɵɵproperty('title', 'title7'); + ɵɵselect(8); + ɵɵproperty('title', 'title8'); + ɵɵselect(9); + ɵɵproperty('title', 'title9'); + ɵɵselect(10); + ɵɵproperty('title', 'title10'); + } +} + + +const rootLView = + setupRootViewWithEmbeddedViews(TestInterpolationComponent_ng_template_0_Template, 11, 10, 1000); +const rootTView = rootLView[TVIEW]; + +// run change detection in the update mode +console.profile('update'); +for (let i = 0; i < 5000; i++) { + refreshView(rootLView, rootTView, null, null); +} +console.profileEnd(); \ No newline at end of file