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

Commit b467422

Browse files
committed
perf(component): add a benchmark that measures component creation with and without css files
1 parent fb7a3aa commit b467422

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-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: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class ViewFactoryInvocaton {
1616
List<Node> elements;
1717

1818
ViewFactoryInvocaton(String template) {
19-
final injector = applicationFactory().run();
19+
final m = new Module()..bind(ComponentWithCss)..bind(ComponentWithoutCss);
20+
21+
final injector = applicationFactory().addModule(m).run();
2022
final directiveMap = injector.get(DirectiveMap);
2123
final compiler = injector.get(Compiler);
2224

@@ -59,13 +61,33 @@ final TEMPLATE_TEXT_WITH_NG_BINDING_3_TIMES = '<span>'
5961
'<span ng-if="1 != 2">right</span>'
6062
'</span>';
6163

64+
final TEMPLATE_COMPONENT_NO_CSS = '<component-without-css></component-without-css>';
65+
66+
final TEMPLATE_COMPONENT_WITH_CSS = '<component-with-css></component-with-css>';
67+
68+
@Component(
69+
selector: 'component-without-css',
70+
template: 'empty'
71+
)
72+
class ComponentWithoutCss {
73+
}
74+
75+
@Component(
76+
selector: 'component-with-css',
77+
template: 'empty',
78+
cssUrl: const ['css1.css', 'css2.css']
79+
)
80+
class ComponentWithCss {
81+
}
6282

6383
void main() {
6484
final templates = {
6585
"(text + ng-binding) * 3" : TEMPLATE_TEXT_WITH_NG_BINDING_3_TIMES,
6686
"text" : TEMPLATE_TEXT_NO_NG_BINDING,
6787
"text + ng-binding" : TEMPLATE_TEXT_WITH_NG_BINDING,
68-
"ng-binding" : TEMPLATE_NO_TEXT_WITH_NG_BINDING
88+
"ng-binding" : TEMPLATE_NO_TEXT_WITH_NG_BINDING,
89+
"component without css" : TEMPLATE_COMPONENT_NO_CSS,
90+
"component with css" : TEMPLATE_COMPONENT_WITH_CSS
6991
};
7092

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

0 commit comments

Comments
 (0)