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:
parent
0602f68ae3
commit
9e36539052
|
@ -28,11 +28,17 @@ export class Reflector {
|
||||||
MapWrapper.set(this._typeInfo, type, typeInfo);
|
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 {
|
factory(type: Type): Function {
|
||||||
if (this._containsTypeInfo(type)) {
|
if (this._containsTypeInfo(type)) {
|
||||||
|
@ -98,6 +104,6 @@ export class Reflector {
|
||||||
_containsTypeInfo(typeOrFunc) { return MapWrapper.contains(this._typeInfo, typeOrFunc); }
|
_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));
|
StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v));
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,3 +40,11 @@ export function microBenchmark(name, iterationCount, callback) {
|
||||||
callback();
|
callback();
|
||||||
window.console.timeEnd(durationName);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/// <reference path="../../typings/node/node.d.ts" />
|
/// <reference path="../../typings/node/node.d.ts" />
|
||||||
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
|
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
|
||||||
|
/// <reference path="../../typings/jasmine/jasmine"/>
|
||||||
|
|
||||||
import webdriver = require('selenium-webdriver');
|
import webdriver = require('selenium-webdriver');
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
/// <reference path="../../typings/node/node.d.ts" />
|
export {verifyNoBrowserErrors} from './e2e_util';
|
||||||
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
|
|
||||||
|
|
||||||
var testUtil = require('./e2e_util');
|
import {bind, Options} from 'benchpress/benchpress';
|
||||||
|
|
||||||
var benchpress = require('benchpress/benchpress');
|
export function runClickBenchmark(config) {
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
runClickBenchmark: runClickBenchmark,
|
|
||||||
runBenchmark: runBenchmark,
|
|
||||||
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
|
|
||||||
};
|
|
||||||
|
|
||||||
function runClickBenchmark(config) {
|
|
||||||
var buttons = config.buttons.map(function(selector) { return $(selector); });
|
var buttons = config.buttons.map(function(selector) { return $(selector); });
|
||||||
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
|
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
|
||||||
return runBenchmark(config);
|
return runBenchmark(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
function runBenchmark(config) {
|
export function runBenchmark(config) {
|
||||||
return getScaleFactor(browser.params.benchmark.scaling)
|
return getScaleFactor(browser.params.benchmark.scaling)
|
||||||
.then(function(scaleFactor) {
|
.then(function(scaleFactor) {
|
||||||
var description = {};
|
var description = {};
|
||||||
|
@ -32,13 +23,12 @@ function runBenchmark(config) {
|
||||||
}
|
}
|
||||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||||
return browser.get(url).then(function() {
|
return browser.get(url).then(function() {
|
||||||
return new benchpress.Runner().sample({
|
return global['benchpressRunner'].sample({
|
||||||
id: config.id,
|
id: config.id,
|
||||||
execute: config.work,
|
execute: config.work,
|
||||||
prepare: config.prepare,
|
prepare: config.prepare,
|
||||||
microMetrics: config.microMetrics,
|
microMetrics: config.microMetrics,
|
||||||
bindings:
|
bindings: [bind(Options.SAMPLE_DESCRIPTION).toValue(description)]
|
||||||
[benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)]
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue