From 9e365390522af8f60b96838f2c7b77c6139700b4 Mon Sep 17 00:00:00 2001 From: Ian Riley Date: Mon, 1 Jun 2015 17:33:51 -0700 Subject: [PATCH] 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. --- modules/angular2/src/reflection/reflector.ts | 14 ++++++++---- .../angular2/src/test_lib/benchmark_util.ts | 8 +++++++ modules/angular2/src/test_lib/e2e_util.ts | 1 + modules/angular2/src/test_lib/perf_util.ts | 22 +++++-------------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/modules/angular2/src/reflection/reflector.ts b/modules/angular2/src/reflection/reflector.ts index 94e7376212..2bc48d885e 100644 --- a/modules/angular2/src/reflection/reflector.ts +++ b/modules/angular2/src/reflection/reflector.ts @@ -28,11 +28,17 @@ export class Reflector { MapWrapper.set(this._typeInfo, type, typeInfo); } - registerGetters(getters: Map): void { _mergeMaps(this._getters, getters); } + registerGetters(getters: StringMap): void { + _mergeMaps(this._getters, getters); + } - registerSetters(setters: Map): void { _mergeMaps(this._setters, setters); } + registerSetters(setters: StringMap): void { + _mergeMaps(this._setters, setters); + } - registerMethods(methods: Map): void { _mergeMaps(this._methods, methods); } + registerMethods(methods: StringMap): 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, config: Map): void { +function _mergeMaps(target: Map, config: StringMap): void { StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v)); } diff --git a/modules/angular2/src/test_lib/benchmark_util.ts b/modules/angular2/src/test_lib/benchmark_util.ts index 38b69fd556..80e6ff5648 100644 --- a/modules/angular2/src/test_lib/benchmark_util.ts +++ b/modules/angular2/src/test_lib/benchmark_util.ts @@ -40,3 +40,11 @@ export function microBenchmark(name, iterationCount, callback) { callback(); window.console.timeEnd(durationName); } + +export function windowProfile(name: string): void { + (window.console).profile(name); +} + +export function windowProfileEnd(name: string): void { + (window.console).profileEnd(name); +} diff --git a/modules/angular2/src/test_lib/e2e_util.ts b/modules/angular2/src/test_lib/e2e_util.ts index 04625a7fa0..4a5d56d8e2 100644 --- a/modules/angular2/src/test_lib/e2e_util.ts +++ b/modules/angular2/src/test_lib/e2e_util.ts @@ -1,5 +1,6 @@ /// /// +/// import webdriver = require('selenium-webdriver'); diff --git a/modules/angular2/src/test_lib/perf_util.ts b/modules/angular2/src/test_lib/perf_util.ts index 296d0f5137..10a45e3496 100644 --- a/modules/angular2/src/test_lib/perf_util.ts +++ b/modules/angular2/src/test_lib/perf_util.ts @@ -1,23 +1,14 @@ -/// -/// +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)] }); }); });