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

Commit

Permalink
perf(component): add a benchmark that measures component creation wit…
Browse files Browse the repository at this point in the history
…h and without css files

Closes #1421
  • Loading branch information
vsavkin committed Sep 14, 2014
1 parent e90fa60 commit 29f3947
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions benchmark/web/view_factory/css1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
one{}
1 change: 1 addition & 0 deletions benchmark/web/view_factory/css2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
two{}
55 changes: 53 additions & 2 deletions benchmark/web/view_factory/view_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ class ViewFactoryInvocaton {
List<Node> elements;

ViewFactoryInvocaton(String template) {
final injector = applicationFactory().run();
final m = new Module()
..bind(ComponentWithCss)
..bind(ComponentWithoutCss)
..bind(ComponentWithEmulatedShadowDomComponent)
..bind(EmulatedShadowDomComponentWithCss);

final injector = applicationFactory().addModule(m).run();
final directiveMap = injector.get(DirectiveMap);
final compiler = injector.get(Compiler);

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

final TEMPLATE_COMPONENT_NO_CSS = '<component-without-css></component-without-css>';

final TEMPLATE_COMPONENT_WITH_CSS = '<component-with-css></component-with-css>';

final TEMPLATE_CONTAINER_COMPONENT = '<component-with-emulated></component-with-emulated>';


@Component(
selector: 'component-without-css',
template: 'empty',
useShadowDom: true
)
class ComponentWithoutCss {
}

@Component(
selector: 'component-with-css',
template: 'empty',
cssUrl: const ['css1.css', 'css2.css'],
useShadowDom: true
)
class ComponentWithCss {
}

@Component(
selector: 'emulated-with-css',
template: 'empty',
cssUrl: const ['css1.css', 'css2.css'],
useShadowDom: false
)
class EmulatedShadowDomComponentWithCss {
}

@Component(
selector: 'component-with-emulated',
template: '<emulated-with-css></emulated-with-css>'
'<emulated-with-css></emulated-with-css>'
'<emulated-with-css></emulated-with-css>',
useShadowDom: true
)
class ComponentWithEmulatedShadowDomComponent {
}

void main() {
final templates = {
"(text + ng-binding) * 3" : TEMPLATE_TEXT_WITH_NG_BINDING_3_TIMES,
"text" : TEMPLATE_TEXT_NO_NG_BINDING,
"text + ng-binding" : TEMPLATE_TEXT_WITH_NG_BINDING,
"ng-binding" : TEMPLATE_NO_TEXT_WITH_NG_BINDING
"ng-binding" : TEMPLATE_NO_TEXT_WITH_NG_BINDING,
"component without css" : TEMPLATE_COMPONENT_NO_CSS,
"component with css" : TEMPLATE_COMPONENT_WITH_CSS,
"component with emulated shadow dom component" : TEMPLATE_CONTAINER_COMPONENT
};

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

0 comments on commit 29f3947

Please sign in to comment.