chore(benchmarks): add transform benchmark runner and clean up benchmark output

This commit is contained in:
Jacob MacDonald 2015-05-07 10:36:04 -07:00
parent e30ad2ec2c
commit 0e2047f9ca
9 changed files with 47 additions and 38 deletions

View File

@ -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);
}

View File

@ -13,14 +13,11 @@ allTests() {
test('Bind Generator Benchmark Runs', runBenchmark);
}
Future runBenchmark() async {
Future<double> 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 = '''

View File

@ -13,16 +13,13 @@ allTests() {
test('Directive Linker Benchmark Runs', runBenchmark);
}
Future runBenchmark() async {
Future<double> 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 = '''

View File

@ -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 = '''

View File

@ -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 = '''

View File

@ -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 = '''

View File

@ -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.');
}

View File

@ -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 = '''

View File

@ -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 = '''