Skip to content

Commit

Permalink
feat(dart/transform): Use the Dart transformer for benchmarks
Browse files Browse the repository at this point in the history
Remove explicit generation of reflection information in benchmark code
and generate it with the transformer.
  • Loading branch information
Tim Blasi committed Apr 10, 2015
1 parent f6e9d1f commit 8212757
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 1,194 deletions.
18 changes: 0 additions & 18 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,24 +564,6 @@ gulp.task('serve/benchmarks_external.dart', pubserve(gulp, gulpPlugins, {
path: CONFIG.dest.dart + '/benchmarks_external'
}));

gulp.task('serve/examples.dart.static', pubserve(gulp, gulpPlugins, {
command: DART_SDK.PUB,
mode: 'ngstatic',
path: CONFIG.dest.dart + '/examples'
}));

gulp.task('serve/benchmarks.dart.static', pubserve(gulp, gulpPlugins, {
command: DART_SDK.PUB,
mode: 'ngstatic',
path: CONFIG.dest.dart + '/benchmarks'
}));

gulp.task('serve/benchmarks_external.dart.static', pubserve(gulp, gulpPlugins, {
command: DART_SDK.PUB,
mode: 'ngstatic',
path: CONFIG.dest.dart + '/benchmarks_external'
}));

// --------------
// doc generation
var Dgeni = require('dgeni');
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ dependencies:
html: '^0.12.0'
stack_trace: '^1.1.1'
transformers:
- angular2/src/transform/di_transformer
- angular2
dev_dependencies:
guinness: "^0.1.17"
8 changes: 7 additions & 1 deletion modules/benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ dependency_overrides:
path: ../angular2
transformers:
- angular2:
entry_point: web/src/di/di_benchmark.dart
entry_points:
- web/src/compiler/compiler_benchmark.dart
- web/src/di/di_benchmark.dart
- web/src/element_injector/element_injector_benchmark.dart
- web/src/largetable/largetable_benchmark.dart
- web/src/naive_infinite_scroll/index.dart
- web/src/tree/tree_benchmark.dart
- $dart2js:
minify: false
commandLineOptions: ['--dump-info', '--trust-type-annotations', '--trust-primitives']
37 changes: 2 additions & 35 deletions modules/benchmarks/src/compiler/compiler_benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_res
import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper';

import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';

import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
Expand All @@ -29,41 +30,7 @@ import {DirectDomRenderer} from 'angular2/src/render/dom/direct_dom_renderer';
import * as rc from 'angular2/src/render/dom/compiler/compiler';

function setupReflector() {
reflector.registerType(BenchmarkComponent, {
"factory": () => new BenchmarkComponent(),
"parameters": [],
"annotations" : [new Component()]
});

reflector.registerType(Dir0, {
"factory": () => new Dir0(),
"parameters": [],
"annotations" : [new Decorator({selector: '[dir0]', properties: {'prop': 'attr0'}})]
});

reflector.registerType(Dir1, {
"factory": (dir0) => new Dir1(dir0),
"parameters": [[Dir0]],
"annotations" : [new Decorator({selector: '[dir1]', properties: {'prop': 'attr1'}})]
});

reflector.registerType(Dir2, {
"factory": (dir1) => new Dir2(dir1),
"parameters": [[Dir1]],
"annotations" : [new Decorator({selector: '[dir2]', properties: {'prop': 'attr2'}})]
});

reflector.registerType(Dir3, {
"factory": (dir2) => new Dir3(dir2),
"parameters": [[Dir2]],
"annotations" : [new Decorator({selector: '[dir3]', properties: {'prop': 'attr3'}})]
});

reflector.registerType(Dir4, {
"factory": (dir3) => new Dir4(dir3),
"parameters": [[Dir3]],
"annotations" : [new Decorator({selector: '[dir4]', properties: {'prop': 'attr4'}})]
});
reflector.reflectionCapabilities = new ReflectionCapabilities();

reflector.registerGetters({
"inter0": (a) => a.inter0, "inter1": (a) => a.inter1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
import {reflector} from 'angular2/src/reflection/reflection';
import {Injector} from 'angular2/di';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
import {Injectable, Injector} from 'angular2/di';
import {ProtoElementInjector} from 'angular2/src/core/compiler/element_injector';
import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/test_lib/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';

var count = 0;

function setupReflector() {
reflector.registerType(A, {
'factory': () => new A(),
'parameters': [],
'annotations' : []
});
reflector.registerType(B, {
'factory': () => new B(),
'parameters': [],
'annotations' : []
});
reflector.registerType(C, {
'factory': (a,b) => new C(a,b),
'parameters': [[A],[B]],
'annotations' : []
});
}

export function main() {
BrowserDomAdapter.makeCurrent();
var iterations = getIntParameter('iterations');

setupReflector();
reflector.reflectionCapabilities = new ReflectionCapabilities();
var appInjector = new Injector([]);

var bindings = [A, B, C];
Expand Down Expand Up @@ -59,18 +42,21 @@ export function main() {
);
}

@Injectable()
class A {
constructor() {
count++;
}
}

@Injectable()
class B {
constructor() {
count++;
}
}

@Injectable()
class C {
constructor(a:A, b:B) {
count++;
Expand Down
Loading

0 comments on commit 8212757

Please sign in to comment.