feat(benchpress): rewritten implementation
Limitations: - cloud reporter is not yet supported any more
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
var benchpress = require('benchpress/index.js');
|
||||
var webdriver = require('protractor/node_modules/selenium-webdriver');
|
||||
var testUtil = require('./test_util');
|
||||
var benchpress = require('benchpress/benchpress');
|
||||
|
||||
module.exports = {
|
||||
runClickBenchmark: runClickBenchmark,
|
||||
runBenchmark: runBenchmark,
|
||||
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors
|
||||
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
|
||||
};
|
||||
|
||||
function runClickBenchmark(config) {
|
||||
@ -16,27 +16,29 @@ function runClickBenchmark(config) {
|
||||
button.click();
|
||||
});
|
||||
}
|
||||
runBenchmark(config);
|
||||
return runBenchmark(config);
|
||||
}
|
||||
|
||||
function runBenchmark(config) {
|
||||
var globalParams = browser.params;
|
||||
getScaleFactor(globalParams.benchmark.scaling).then(function(scaleFactor) {
|
||||
var params = config.params.map(function(param) {
|
||||
return {
|
||||
name: param.name, value: applyScaleFactor(param.value, scaleFactor, param.scale)
|
||||
}
|
||||
return getScaleFactor(browser.params.benchmark.scaling).then(function(scaleFactor) {
|
||||
var description = {};
|
||||
var urlParams = [];
|
||||
config.params.forEach(function(param) {
|
||||
var name = param.name;
|
||||
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
||||
urlParams.push(name + '=' + value);
|
||||
description[name] = value;
|
||||
});
|
||||
var benchmarkConfig = Object.create(globalParams.benchmark);
|
||||
benchmarkConfig.id = globalParams.lang+'.'+config.id;
|
||||
benchmarkConfig.params = params;
|
||||
benchmarkConfig.scaleFactor = scaleFactor;
|
||||
|
||||
var url = encodeURI(config.url + '?' + params.map(function(param) {
|
||||
return param.name + '=' + param.value;
|
||||
}).join('&'));
|
||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||
browser.get(url);
|
||||
benchpress.runBenchmark(benchmarkConfig, config.work);
|
||||
return benchpressRunner.sample({
|
||||
id: config.id,
|
||||
execute: config.work,
|
||||
prepare: config.prepare,
|
||||
bindings: [
|
||||
benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
var benchpress = require('benchpress/index.js');
|
||||
var webdriver = require('selenium-webdriver');
|
||||
|
||||
module.exports = {
|
||||
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors,
|
||||
verifyNoBrowserErrors: verifyNoBrowserErrors,
|
||||
clickAll: clickAll
|
||||
};
|
||||
|
||||
@ -10,3 +10,19 @@ function clickAll(buttonSelectors) {
|
||||
$(selector).click();
|
||||
});
|
||||
}
|
||||
|
||||
function verifyNoBrowserErrors() {
|
||||
// TODO(tbosch): Bug in ChromeDriver: Need to execute at least one command
|
||||
// so that the browser logs can be read out!
|
||||
browser.executeScript('1+1');
|
||||
browser.manage().logs().get('browser').then(function(browserLog) {
|
||||
var filteredLog = browserLog.filter(function(logEntry) {
|
||||
return logEntry.level.value > webdriver.logging.Level.WARNING.value;
|
||||
});
|
||||
expect(filteredLog.length).toEqual(0);
|
||||
if (filteredLog.length) {
|
||||
console.log('browser console errors: ' + require('util').inspect(filteredLog));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
19
modules/angular2/src/di/exceptions.js
vendored
19
modules/angular2/src/di/exceptions.js
vendored
@ -1,6 +1,5 @@
|
||||
import {ListWrapper, List} from 'angular2/src/facade/collection';
|
||||
import {stringify} from 'angular2/src/facade/lang';
|
||||
import {Key} from './key';
|
||||
|
||||
function findFirstClosedCycle(keys:List) {
|
||||
var res = [];
|
||||
@ -31,14 +30,16 @@ export class ProviderError extends Error {
|
||||
keys:List;
|
||||
constructResolvingMessage:Function;
|
||||
message;
|
||||
constructor(key:Key, constructResolvingMessage:Function) {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key, constructResolvingMessage:Function) {
|
||||
super();
|
||||
this.keys = [key];
|
||||
this.constructResolvingMessage = constructResolvingMessage;
|
||||
this.message = this.constructResolvingMessage(this.keys);
|
||||
}
|
||||
|
||||
addKey(key:Key) {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
addKey(key) {
|
||||
ListWrapper.push(this.keys, key);
|
||||
this.message = this.constructResolvingMessage(this.keys);
|
||||
}
|
||||
@ -49,7 +50,8 @@ export class ProviderError extends Error {
|
||||
}
|
||||
|
||||
export class NoProviderError extends ProviderError {
|
||||
constructor(key:Key) {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key) {
|
||||
super(key, function (keys:List) {
|
||||
var first = stringify(ListWrapper.first(keys).token);
|
||||
return `No provider for ${first}!${constructResolvingPath(keys)}`;
|
||||
@ -58,7 +60,8 @@ export class NoProviderError extends ProviderError {
|
||||
}
|
||||
|
||||
export class AsyncBindingError extends ProviderError {
|
||||
constructor(key:Key) {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key) {
|
||||
super(key, function (keys:List) {
|
||||
var first = stringify(ListWrapper.first(keys).token);
|
||||
return `Cannot instantiate ${first} synchronously. ` +
|
||||
@ -68,7 +71,8 @@ export class AsyncBindingError extends ProviderError {
|
||||
}
|
||||
|
||||
export class CyclicDependencyError extends ProviderError {
|
||||
constructor(key:Key) {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(key) {
|
||||
super(key, function (keys:List) {
|
||||
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
|
||||
});
|
||||
@ -76,7 +80,8 @@ export class CyclicDependencyError extends ProviderError {
|
||||
}
|
||||
|
||||
export class InstantiationError extends ProviderError {
|
||||
constructor(originalException, key:Key) {
|
||||
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
|
||||
constructor(originalException, key) {
|
||||
super(key, function (keys:List) {
|
||||
var first = stringify(ListWrapper.first(keys).token);
|
||||
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.` +
|
||||
|
@ -98,8 +98,7 @@ class ListWrapper {
|
||||
l.add(e);
|
||||
}
|
||||
static List concat(List a, List b) {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
return []..addAll(a)..addAll(b);
|
||||
}
|
||||
static bool isList(l) => l is List;
|
||||
static void insert(List l, int index, value) {
|
||||
|
@ -2,6 +2,7 @@ library angular.core.facade.lang;
|
||||
|
||||
export 'dart:core' show Type, RegExp, print;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:convert' as convert;
|
||||
|
||||
class Math {
|
||||
static final _random = new math.Random();
|
||||
@ -176,3 +177,9 @@ bool assertionsEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Can't be all uppercase as our transpiler would think it is a special directive...
|
||||
class Json {
|
||||
static parse(String s) => convert.JSON.decode(s);
|
||||
static stringify(data) => convert.JSON.encode(data);
|
||||
}
|
||||
|
@ -247,3 +247,6 @@ export function print(obj) {
|
||||
console.log(obj);
|
||||
}
|
||||
}
|
||||
|
||||
// Can't be all uppercase as our transpiler would think it is a special directive...
|
||||
export var Json = _global.JSON;
|
||||
|
@ -1,7 +1,10 @@
|
||||
library angular.core.facade.math;
|
||||
|
||||
import 'dart:core' show double, num;
|
||||
import 'dart:math' as math;
|
||||
|
||||
var NaN = double.NAN;
|
||||
|
||||
class Math {
|
||||
static num pow(num x, num exponent) {
|
||||
return math.pow(x, exponent);
|
||||
@ -10,4 +13,8 @@ class Math {
|
||||
static num min(num a, num b) => math.min(a, b);
|
||||
|
||||
static num floor(num a) => a.floor();
|
||||
|
||||
static num ceil(num a) => a.ceil();
|
||||
|
||||
static num sqrt(num x) => math.sqrt(x);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import {global} from 'angular2/src/facade/lang';
|
||||
|
||||
export var Math = global.Math;
|
||||
export var Math = global.Math;
|
||||
export var NaN = global.NaN;
|
||||
|
@ -26,6 +26,7 @@ class Expect extends gns.Expect {
|
||||
void toThrowError([message=""]) => this.toThrowWith(message: message);
|
||||
void toBePromise() => _expect(actual is Future, equals(true));
|
||||
void toImplement(expected) => toBeA(expected);
|
||||
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
|
||||
Function get _expect => gns.guinness.matchers.expect;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user