diff --git a/modules/angular2/test/benchmark/transform/benchmark.transform.server.spec.dart b/modules/angular2/test/benchmark/transform/benchmark.transform.server.spec.dart index 736bffd6b3..424200d4f6 100644 --- a/modules/angular2/test/benchmark/transform/benchmark.transform.server.spec.dart +++ b/modules/angular2/test/benchmark/transform/benchmark.transform.server.spec.dart @@ -1,5 +1,7 @@ library angular2.test.benchmark.transform; +import 'package:angular2/src/transform/common/formatter.dart' as formatter; +import 'package:dart_style/dart_style.dart'; import 'package:guinness/guinness.dart'; import 'package:unittest/vm_config.dart'; @@ -13,12 +15,13 @@ import 'template_compiler/url.dart' as urlTemplateCompiler; main() { useVMConfiguration(); + formatter.init(new DartFormatter()); describe('Bind Generator Benchmark', bindGenerator.allTests); describe('Directive Linker Benchmark', directiveLinker.allTests); describe('Directive Processor Benchmark', directiveProcessor.allTests); describe('Hello World Transformer Benchmark', helloWorld.allTests); describe('Reflection Remover Benchmark', reflectionRemover.allTests); - describe('Inline Template Compiler Benchmark', - inlineTemplateCompiler.allTests); + describe( + 'Inline Template Compiler Benchmark', inlineTemplateCompiler.allTests); describe('Url Template Compiler Benchmark', urlTemplateCompiler.allTests); } diff --git a/modules/angular2/test/benchmark/transform/bind_generator/simple.dart b/modules/angular2/test/benchmark/transform/bind_generator/simple.dart index 81c9f26e42..97777c5846 100644 --- a/modules/angular2/test/benchmark/transform/bind_generator/simple.dart +++ b/modules/angular2/test/benchmark/transform/bind_generator/simple.dart @@ -13,14 +13,11 @@ allTests() { test('Bind Generator Benchmark Runs', runBenchmark); } -Future runBenchmark() async { +Future runBenchmark() async { var options = new TransformerOptions(['this_is_ignored.dart']); var files = {new AssetId('a', 'a.ng_deps.dart'): aContents}; - var benchmark = - new TransformerBenchmark([[new BindGenerator(options)]], files); - print('\nRunning bind_generator benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark([[new BindGenerator(options)]], files) + .measure(); } const aContents = ''' diff --git a/modules/angular2/test/benchmark/transform/directive_linker/simple.dart b/modules/angular2/test/benchmark/transform/directive_linker/simple.dart index ab4c7f41d3..46db976e8c 100644 --- a/modules/angular2/test/benchmark/transform/directive_linker/simple.dart +++ b/modules/angular2/test/benchmark/transform/directive_linker/simple.dart @@ -13,16 +13,13 @@ allTests() { test('Directive Linker Benchmark Runs', runBenchmark); } -Future runBenchmark() async { +Future runBenchmark() async { var files = { new AssetId('a', 'a.ng_deps.dart'): aContents, new AssetId('a', 'b.ng_deps.dart'): bContents, new AssetId('a', 'c.ng_deps.dart'): cContents, }; - var benchmark = new TransformerBenchmark([[new DirectiveLinker()]], files); - print('\nRunning directive_linker benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark([[new DirectiveLinker()]], files).measure(); } const aContents = ''' diff --git a/modules/angular2/test/benchmark/transform/directive_processor/simple.dart b/modules/angular2/test/benchmark/transform/directive_processor/simple.dart index 28ddaa9ed9..5b5ad5125e 100644 --- a/modules/angular2/test/benchmark/transform/directive_processor/simple.dart +++ b/modules/angular2/test/benchmark/transform/directive_processor/simple.dart @@ -16,11 +16,8 @@ allTests() { Future runBenchmark() async { var options = new TransformerOptions(['this_is_ignored.dart']); var files = {new AssetId('a', 'a.dart'): aContents,}; - var benchmark = - new TransformerBenchmark([[new DirectiveProcessor(options)]], files); - print('\nRunning directive_processor benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark([[new DirectiveProcessor(options)]], files) + .measure(); } const aContents = ''' diff --git a/modules/angular2/test/benchmark/transform/integration/hello_world.dart b/modules/angular2/test/benchmark/transform/integration/hello_world.dart index 60aeb5bb86..cd2c3d40e9 100644 --- a/modules/angular2/test/benchmark/transform/integration/hello_world.dart +++ b/modules/angular2/test/benchmark/transform/integration/hello_world.dart @@ -19,11 +19,8 @@ Future runBenchmark() async { new AssetId('a', 'web/index.dart'): indexContents, new AssetId('a', 'web/index_common.dart'): indexCommonContents, }; - var benchmark = new TransformerBenchmark( - new AngularTransformerGroup(options).phases, files); - print('\nRunning hello_world benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark( + new AngularTransformerGroup(options).phases, files).measure(); } const indexContents = ''' diff --git a/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart b/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart index 2e08fc90e6..661bce5ad7 100644 --- a/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart +++ b/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart @@ -16,11 +16,8 @@ allTests() { Future runBenchmark() async { var options = new TransformerOptions(['web/index.dart']); var files = {new AssetId('a', 'web/index.dart'): indexContents,}; - var benchmark = - new TransformerBenchmark([[new ReflectionRemover(options)]], files); - print('\nRunning reflection_remover benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark([[new ReflectionRemover(options)]], files) + .measure(); } const indexContents = ''' diff --git a/modules/angular2/test/benchmark/transform/run_all.dart b/modules/angular2/test/benchmark/transform/run_all.dart new file mode 100644 index 0000000000..1b3e7b4a02 --- /dev/null +++ b/modules/angular2/test/benchmark/transform/run_all.dart @@ -0,0 +1,27 @@ +library angular2.test.benchmark.transform.run_all; + +import 'package:angular2/src/transform/common/formatter.dart' as formatter; +import 'package:dart_style/dart_style.dart'; + +import 'bind_generator/simple.dart' as bindGenerator; +import 'directive_linker/simple.dart' as directiveLinker; +import 'directive_processor/simple.dart' as directiveProcessor; +import 'integration/hello_world.dart' as helloWorld; +import 'reflection_remover/simple.dart' as reflectionRemover; +import 'template_compiler/inline.dart' as inlineTemplateCompiler; +import 'template_compiler/url.dart' as urlTemplateCompiler; + +main() async { + formatter.init(new DartFormatter()); + printResult('BindGenerator', await bindGenerator.runBenchmark()); + printResult('DirectiveLinker', await directiveLinker.runBenchmark()); + printResult('HelloWorld', await helloWorld.runBenchmark()); + printResult('ReflectionRemover', await reflectionRemover.runBenchmark()); + printResult( + 'InlineTemplateCompiler', await inlineTemplateCompiler.runBenchmark()); + printResult('UrlTemplateCompiler', await urlTemplateCompiler.runBenchmark()); +} + +void printResult(String name, double result) { + print('ng2.transform.$name(RunTime): $result us.'); +} diff --git a/modules/angular2/test/benchmark/transform/template_compiler/inline.dart b/modules/angular2/test/benchmark/transform/template_compiler/inline.dart index e92fcaa5d2..da99194513 100644 --- a/modules/angular2/test/benchmark/transform/template_compiler/inline.dart +++ b/modules/angular2/test/benchmark/transform/template_compiler/inline.dart @@ -16,11 +16,8 @@ allTests() { Future runBenchmark() async { var options = new TransformerOptions(['index.dart']); var files = {new AssetId('a', 'web/a.ng_deps.dart'): aContents,}; - var benchmark = - new TransformerBenchmark([[new TemplateCompiler(options)]], files); - print('\nRunning template_compiler inline benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark([[new TemplateCompiler(options)]], files) + .measure(); } const aContents = ''' diff --git a/modules/angular2/test/benchmark/transform/template_compiler/url.dart b/modules/angular2/test/benchmark/transform/template_compiler/url.dart index a667d688ea..681f57ab5a 100644 --- a/modules/angular2/test/benchmark/transform/template_compiler/url.dart +++ b/modules/angular2/test/benchmark/transform/template_compiler/url.dart @@ -19,11 +19,8 @@ Future runBenchmark() async { new AssetId('a', 'web/a.ng_deps.dart'): aContents, new AssetId('a', 'web/template.html'): templateContents, }; - var benchmark = - new TransformerBenchmark([[new TemplateCompiler(options)]], files); - print('\nRunning template_compiler url benchmark...'); - var result = await benchmark.measure(); - print('Done, took ${result.round()}μs on average.'); + return new TransformerBenchmark([[new TemplateCompiler(options)]], files) + .measure(); } const aContents = '''