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.
This commit is contained in:
Ian Riley 2015-06-01 17:33:51 -07:00 committed by Tobias Bosch
parent 0602f68ae3
commit 9e36539052
4 changed files with 25 additions and 20 deletions

View File

@ -28,11 +28,17 @@ export class Reflector {
MapWrapper.set(this._typeInfo, type, typeInfo);
}
registerGetters(getters: Map<string, GetterFn>): void { _mergeMaps(this._getters, getters); }
registerGetters(getters: StringMap<string, GetterFn>): void {
_mergeMaps(this._getters, getters);
}
registerSetters(setters: Map<string, SetterFn>): void { _mergeMaps(this._setters, setters); }
registerSetters(setters: StringMap<string, SetterFn>): void {
_mergeMaps(this._setters, setters);
}
registerMethods(methods: Map<string, MethodFn>): void { _mergeMaps(this._methods, methods); }
registerMethods(methods: StringMap<string, MethodFn>): void {
_mergeMaps(this._methods, methods);
}
factory(type: Type): Function {
if (this._containsTypeInfo(type)) {
@ -98,6 +104,6 @@ export class Reflector {
_containsTypeInfo(typeOrFunc) { return MapWrapper.contains(this._typeInfo, typeOrFunc); }
}
function _mergeMaps(target: Map<any, any>, config: Map<string, Function>): void {
function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void {
StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v));
}

View File

@ -40,3 +40,11 @@ export function microBenchmark(name, iterationCount, callback) {
callback();
window.console.timeEnd(durationName);
}
export function windowProfile(name: string): void {
(<any>window.console).profile(name);
}
export function windowProfileEnd(name: string): void {
(<any>window.console).profileEnd(name);
}

View File

@ -1,5 +1,6 @@
/// <reference path="../../typings/node/node.d.ts" />
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
/// <reference path="../../typings/jasmine/jasmine"/>
import webdriver = require('selenium-webdriver');

View File

@ -1,23 +1,14 @@
/// <reference path="../../typings/node/node.d.ts" />
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
export {verifyNoBrowserErrors} from './e2e_util';
var testUtil = require('./e2e_util');
import {bind, Options} from 'benchpress/benchpress';
var benchpress = require('benchpress/benchpress');
module.exports = {
runClickBenchmark: runClickBenchmark,
runBenchmark: runBenchmark,
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
};
function runClickBenchmark(config) {
export function runClickBenchmark(config) {
var buttons = config.buttons.map(function(selector) { return $(selector); });
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
return runBenchmark(config);
}
function runBenchmark(config) {
export function runBenchmark(config) {
return getScaleFactor(browser.params.benchmark.scaling)
.then(function(scaleFactor) {
var description = {};
@ -32,13 +23,12 @@ function runBenchmark(config) {
}
var url = encodeURI(config.url + '?' + urlParams.join('&'));
return browser.get(url).then(function() {
return new benchpress.Runner().sample({
return global['benchpressRunner'].sample({
id: config.id,
execute: config.work,
prepare: config.prepare,
microMetrics: config.microMetrics,
bindings:
[benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)]
bindings: [bind(Options.SAMPLE_DESCRIPTION).toValue(description)]
});
});
});