Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 94da991

Browse files
vsavkinVictor Savkin
authored and
Victor Savkin
committed
perf(component): add a benchmark that measures component creation with and without css files
Closes #1421
1 parent 238120b commit 94da991

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

benchmark/web/view_factory/css1.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
one{}

benchmark/web/view_factory/css2.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
two{}

benchmark/web/view_factory/view_factory.dart

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ class ViewFactoryInvocaton {
1616
List<Node> elements;
1717

1818
ViewFactoryInvocaton(String template) {
19-
final injector = applicationFactory().run();
19+
final m = new Module()
20+
..bind(ComponentWithCss)
21+
..bind(ComponentWithoutCss)
22+
..bind(ComponentWithEmulatedShadowDomComponent)
23+
..bind(EmulatedShadowDomComponentWithCss);
24+
25+
final injector = applicationFactory().addModule(m).run();
2026
final directiveMap = injector.get(DirectiveMap);
2127
final compiler = injector.get(Compiler);
2228

@@ -59,13 +65,58 @@ final TEMPLATE_TEXT_WITH_NG_BINDING_3_TIMES = '<span>'
5965
'<span ng-if="1 != 2">right</span>'
6066
'</span>';
6167

68+
final TEMPLATE_COMPONENT_NO_CSS = '<component-without-css></component-without-css>';
69+
70+
final TEMPLATE_COMPONENT_WITH_CSS = '<component-with-css></component-with-css>';
71+
72+
final TEMPLATE_CONTAINER_COMPONENT = '<component-with-emulated></component-with-emulated>';
73+
74+
75+
@Component(
76+
selector: 'component-without-css',
77+
template: 'empty',
78+
useShadowDom: true
79+
)
80+
class ComponentWithoutCss {
81+
}
82+
83+
@Component(
84+
selector: 'component-with-css',
85+
template: 'empty',
86+
cssUrl: const ['css1.css', 'css2.css'],
87+
useShadowDom: true
88+
)
89+
class ComponentWithCss {
90+
}
91+
92+
@Component(
93+
selector: 'emulated-with-css',
94+
template: 'empty',
95+
cssUrl: const ['css1.css', 'css2.css'],
96+
useShadowDom: false
97+
)
98+
class EmulatedShadowDomComponentWithCss {
99+
}
100+
101+
@Component(
102+
selector: 'component-with-emulated',
103+
template: '<emulated-with-css></emulated-with-css>'
104+
'<emulated-with-css></emulated-with-css>'
105+
'<emulated-with-css></emulated-with-css>',
106+
useShadowDom: true
107+
)
108+
class ComponentWithEmulatedShadowDomComponent {
109+
}
62110

63111
void main() {
64112
final templates = {
65113
"(text + ng-binding) * 3" : TEMPLATE_TEXT_WITH_NG_BINDING_3_TIMES,
66114
"text" : TEMPLATE_TEXT_NO_NG_BINDING,
67115
"text + ng-binding" : TEMPLATE_TEXT_WITH_NG_BINDING,
68-
"ng-binding" : TEMPLATE_NO_TEXT_WITH_NG_BINDING
116+
"ng-binding" : TEMPLATE_NO_TEXT_WITH_NG_BINDING,
117+
"component without css" : TEMPLATE_COMPONENT_NO_CSS,
118+
"component with css" : TEMPLATE_COMPONENT_WITH_CSS,
119+
"component with emulated shadow dom component" : TEMPLATE_CONTAINER_COMPONENT
69120
};
70121

71122
final t = document.querySelector("#templates");

0 commit comments

Comments
 (0)