From 6126599e603444ed53584264ec68139e58720bbd Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 3 Sep 2014 08:34:45 -0400 Subject: [PATCH] perf(component): add a benchmark that measures component creation with and without css files --- benchmark/web/view_factory/css1.css | 1 + benchmark/web/view_factory/css2.css | 1 + benchmark/web/view_factory/view_factory.dart | 55 +++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 benchmark/web/view_factory/css1.css create mode 100644 benchmark/web/view_factory/css2.css diff --git a/benchmark/web/view_factory/css1.css b/benchmark/web/view_factory/css1.css new file mode 100644 index 000000000..b9a7e2645 --- /dev/null +++ b/benchmark/web/view_factory/css1.css @@ -0,0 +1 @@ +one{} \ No newline at end of file diff --git a/benchmark/web/view_factory/css2.css b/benchmark/web/view_factory/css2.css new file mode 100644 index 000000000..4575cd4dd --- /dev/null +++ b/benchmark/web/view_factory/css2.css @@ -0,0 +1 @@ +two{} \ No newline at end of file diff --git a/benchmark/web/view_factory/view_factory.dart b/benchmark/web/view_factory/view_factory.dart index b8dd2c528..ebbf229da 100644 --- a/benchmark/web/view_factory/view_factory.dart +++ b/benchmark/web/view_factory/view_factory.dart @@ -16,7 +16,13 @@ class ViewFactoryInvocaton { List 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); @@ -59,13 +65,58 @@ final TEMPLATE_TEXT_WITH_NG_BINDING_3_TIMES = '' 'right' ''; +final TEMPLATE_COMPONENT_NO_CSS = ''; + +final TEMPLATE_COMPONENT_WITH_CSS = ''; + +final TEMPLATE_CONTAINER_COMPONENT = ''; + + +@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: '' + '' + '', + 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");