test(ivy): introduce a benchmark for duplicate style/class bindings (#33600)

Prior to this patch all the styling benchmarks only tested for
template-based style/class bindings. Because of each of the bindings
being only present in the template, there was no possibility of
there being any duplicate bindings. This benchmark introduces
style/class bindings being evaluated from both a template and from
various directives.

This benchmark can be executed by calling:

```
bazel build //packages/core/test/render3/perf:duplicate_style_and_class_bindings_lib.min_debug.es2015.js

node dist/bin/packages/core/test/render3/perf/duplicate_style_and_class_bindings_lib.min_debug.es2015.js
```

The benchmark is also run via the `profile_all.js` script (found in
`packages/core/test/render3/perf/`)

PR Close #33600
This commit is contained in:
Matias Niemelä
2019-11-05 12:14:03 -08:00
committed by Andrew Scott
parent 8164d28b6c
commit 854a377232
4 changed files with 220 additions and 6 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {addToViewTree, createLContainer, createLView, createTNode, createTView, getOrCreateTNode, refreshView, renderView} from '../../../src/render3/instructions/shared';
import {ComponentTemplate} from '../../../src/render3/interfaces/definition';
import {ComponentTemplate, DirectiveDefList} from '../../../src/render3/interfaces/definition';
import {TAttributes, TNodeType, TViewNode} from '../../../src/render3/interfaces/node';
import {RendererFactory3, domRendererFactory3} from '../../../src/render3/interfaces/renderer';
import {LView, LViewFlags, TView, TViewType} from '../../../src/render3/interfaces/view';
@ -28,8 +28,10 @@ export function createAndRenderLView(
export function setupRootViewWithEmbeddedViews(
templateFn: ComponentTemplate<any>| null, decls: number, vars: number, noOfViews: number,
embeddedViewContext: any = {}, consts: TAttributes[] | null = null): LView {
return setupTestHarness(templateFn, decls, vars, noOfViews, embeddedViewContext, consts)
embeddedViewContext: any = {}, consts: TAttributes[] | null = null,
directiveRegistry: DirectiveDefList | null = null): LView {
return setupTestHarness(
templateFn, decls, vars, noOfViews, embeddedViewContext, consts, directiveRegistry)
.hostLView;
}
@ -43,7 +45,8 @@ export interface TestHarness {
export function setupTestHarness(
templateFn: ComponentTemplate<any>| null, decls: number, vars: number, noOfViews: number,
embeddedViewContext: any = {}, consts: TAttributes[] | null = null): TestHarness {
embeddedViewContext: any = {}, consts: TAttributes[] | null = null,
directiveRegistry: DirectiveDefList | null = null): TestHarness {
// Create a root view with a container
const hostTView = createTView(TViewType.Root, -1, null, 1, 0, null, null, null, null, consts);
const tContainerNode = getOrCreateTNode(hostTView, null, 0, TNodeType.Container, null, null);
@ -58,8 +61,8 @@ export function setupTestHarness(
// create test embedded views
const embeddedTView =
createTView(TViewType.Embedded, -1, templateFn, decls, vars, null, null, null, null, consts);
const embeddedTView = createTView(
TViewType.Embedded, -1, templateFn, decls, vars, directiveRegistry, null, null, null, consts);
const viewTNode = createTNode(hostTView, null, TNodeType.View, -1, null, null) as TViewNode;
function createEmbeddedLView(): LView {