Skip to content

Commit

Permalink
test(ivy): add property binding node-based micro benchmark (angular#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource authored and sabeersulaiman committed Sep 6, 2019
1 parent 02e68d6 commit 1588476
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/core/test/render3/perf/BUILD.bazel
Expand Up @@ -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",
],
)
4 changes: 1 addition & 3 deletions packages/core/test/render3/perf/noop_renderer.ts
Expand Up @@ -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,
Expand Down
71 changes: 71 additions & 0 deletions 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';

`<div>
<button [title]="'title1'"></button>
<button [title]="'title2'"></button>
<button [title]="'title3'"></button>
<button [title]="'title4'"></button>
<button [title]="'title5'"></button>
<button [title]="'title6'"></button>
<button [title]="'title7'"></button>
<button [title]="'title8'"></button>
<button [title]="'title9'"></button>
<button [title]="'title10'"></button>
</div>
</ng-template>`;
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();

0 comments on commit 1588476

Please sign in to comment.