test(ivy): add property binding node-based micro benchmark (#32104)

PR Close #32104
This commit is contained in:
Pawel Kozlowski 2019-08-12 12:47:26 +02:00 committed by Andrew Kushnir
parent 33fab26930
commit f41c41fd50
3 changed files with 80 additions and 3 deletions

View File

@ -27,3 +27,11 @@ ng_rollup_bundle(
":perf_lib", ":perf_lib",
], ],
) )
ng_rollup_bundle(
name = "property_binding",
entry_point = ":property_binding/index.ts",
deps = [
":perf_lib",
],
)

View File

@ -38,9 +38,7 @@ export class NoopRenderer implements ProceduralRenderer3 {
removeStyle(el: RElement, style: string, flags?: RendererStyleFlags3|undefined): void { removeStyle(el: RElement, style: string, flags?: RendererStyleFlags3|undefined): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
setProperty(el: RElement, name: string, value: any): void { setProperty(el: RElement, name: string, value: any): void { (el as any)[name] = value; }
throw new Error('Method not implemented.');
}
setValue(node: RComment|RText, value: string): void { node.textContent = value; } setValue(node: RComment|RText, value: string): void { node.textContent = value; }
listen( listen(
target: RNode|'document'|'window'|'body', eventName: string, target: RNode|'document'|'window'|'body', eventName: string,

View File

@ -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();