Skip to content

Commit 9e36539

Browse files
ttowncompiledtbosch
authored andcommitted
fix(src/reflection && src/test_lib): Fixes bugs that caused benchmarks to fail.
Adjusts src/test_lib files to adhere to common TS module practices. Fixes bug with all files that causes benchmarks to fail.
1 parent 0602f68 commit 9e36539

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

modules/angular2/src/reflection/reflector.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ export class Reflector {
2828
MapWrapper.set(this._typeInfo, type, typeInfo);
2929
}
3030

31-
registerGetters(getters: Map<string, GetterFn>): void { _mergeMaps(this._getters, getters); }
31+
registerGetters(getters: StringMap<string, GetterFn>): void {
32+
_mergeMaps(this._getters, getters);
33+
}
3234

33-
registerSetters(setters: Map<string, SetterFn>): void { _mergeMaps(this._setters, setters); }
35+
registerSetters(setters: StringMap<string, SetterFn>): void {
36+
_mergeMaps(this._setters, setters);
37+
}
3438

35-
registerMethods(methods: Map<string, MethodFn>): void { _mergeMaps(this._methods, methods); }
39+
registerMethods(methods: StringMap<string, MethodFn>): void {
40+
_mergeMaps(this._methods, methods);
41+
}
3642

3743
factory(type: Type): Function {
3844
if (this._containsTypeInfo(type)) {
@@ -98,6 +104,6 @@ export class Reflector {
98104
_containsTypeInfo(typeOrFunc) { return MapWrapper.contains(this._typeInfo, typeOrFunc); }
99105
}
100106

101-
function _mergeMaps(target: Map<any, any>, config: Map<string, Function>): void {
107+
function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void {
102108
StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v));
103109
}

modules/angular2/src/test_lib/benchmark_util.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ export function microBenchmark(name, iterationCount, callback) {
4040
callback();
4141
window.console.timeEnd(durationName);
4242
}
43+
44+
export function windowProfile(name: string): void {
45+
(<any>window.console).profile(name);
46+
}
47+
48+
export function windowProfileEnd(name: string): void {
49+
(<any>window.console).profileEnd(name);
50+
}

modules/angular2/src/test_lib/e2e_util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference path="../../typings/node/node.d.ts" />
22
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
3+
/// <reference path="../../typings/jasmine/jasmine"/>
34

45
import webdriver = require('selenium-webdriver');
56

modules/angular2/src/test_lib/perf_util.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
/// <reference path="../../typings/node/node.d.ts" />
2-
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
1+
export {verifyNoBrowserErrors} from './e2e_util';
32

4-
var testUtil = require('./e2e_util');
3+
import {bind, Options} from 'benchpress/benchpress';
54

6-
var benchpress = require('benchpress/benchpress');
7-
8-
module.exports = {
9-
runClickBenchmark: runClickBenchmark,
10-
runBenchmark: runBenchmark,
11-
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
12-
};
13-
14-
function runClickBenchmark(config) {
5+
export function runClickBenchmark(config) {
156
var buttons = config.buttons.map(function(selector) { return $(selector); });
167
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
178
return runBenchmark(config);
189
}
1910

20-
function runBenchmark(config) {
11+
export function runBenchmark(config) {
2112
return getScaleFactor(browser.params.benchmark.scaling)
2213
.then(function(scaleFactor) {
2314
var description = {};
@@ -32,13 +23,12 @@ function runBenchmark(config) {
3223
}
3324
var url = encodeURI(config.url + '?' + urlParams.join('&'));
3425
return browser.get(url).then(function() {
35-
return new benchpress.Runner().sample({
26+
return global['benchpressRunner'].sample({
3627
id: config.id,
3728
execute: config.work,
3829
prepare: config.prepare,
3930
microMetrics: config.microMetrics,
40-
bindings:
41-
[benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)]
31+
bindings: [bind(Options.SAMPLE_DESCRIPTION).toValue(description)]
4232
});
4333
});
4434
});

0 commit comments

Comments
 (0)