Skip to content

Commit f6284f2

Browse files
committed
feat(benchpress): rewritten implementation
Limitations: - cloud reporter is not yet supported any more
1 parent 4484583 commit f6284f2

78 files changed

Lines changed: 2666 additions & 1018 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ gulp.task('build/transpile.js.prod', function(done) {
272272
});
273273

274274
gulp.task('build/transpile.js.cjs', transpile(gulp, gulpPlugins, {
275-
src: CONFIG.transpile.src.js.concat(['tools/benchp*/**/*.es6']),
275+
src: CONFIG.transpile.src.js,
276276
copy: CONFIG.transpile.copy.js,
277277
dest: CONFIG.dest.js.cjs,
278278
outputExt: 'js',

karma-dart.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = function(config) {
4343

4444
// Local dependencies, transpiled from the source.
4545
'/packages/angular': 'http://localhost:9877/base/modules/angular',
46+
'/packages/benchpress': 'http://localhost:9877/base/modules/benchpress',
4647
'/packages/core': 'http://localhost:9877/base/modules/core',
4748
'/packages/change_detection': 'http://localhost:9877/base/modules/change_detection',
4849
'/packages/reflection': 'http://localhost:9877/base/modules/reflection',

modules/angular2/e2e_test/perf_util.es6

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var benchpress = require('benchpress/index.js');
2-
var webdriver = require('protractor/node_modules/selenium-webdriver');
1+
var testUtil = require('./test_util');
2+
var benchpress = require('benchpress/benchpress');
33

44
module.exports = {
55
runClickBenchmark: runClickBenchmark,
66
runBenchmark: runBenchmark,
7-
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors
7+
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
88
};
99

1010
function runClickBenchmark(config) {
@@ -16,27 +16,29 @@ function runClickBenchmark(config) {
1616
button.click();
1717
});
1818
}
19-
runBenchmark(config);
19+
return runBenchmark(config);
2020
}
2121

2222
function runBenchmark(config) {
23-
var globalParams = browser.params;
24-
getScaleFactor(globalParams.benchmark.scaling).then(function(scaleFactor) {
25-
var params = config.params.map(function(param) {
26-
return {
27-
name: param.name, value: applyScaleFactor(param.value, scaleFactor, param.scale)
28-
}
23+
return getScaleFactor(browser.params.benchmark.scaling).then(function(scaleFactor) {
24+
var description = {};
25+
var urlParams = [];
26+
config.params.forEach(function(param) {
27+
var name = param.name;
28+
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
29+
urlParams.push(name + '=' + value);
30+
description[name] = value;
2931
});
30-
var benchmarkConfig = Object.create(globalParams.benchmark);
31-
benchmarkConfig.id = globalParams.lang+'.'+config.id;
32-
benchmarkConfig.params = params;
33-
benchmarkConfig.scaleFactor = scaleFactor;
34-
35-
var url = encodeURI(config.url + '?' + params.map(function(param) {
36-
return param.name + '=' + param.value;
37-
}).join('&'));
32+
var url = encodeURI(config.url + '?' + urlParams.join('&'));
3833
browser.get(url);
39-
benchpress.runBenchmark(benchmarkConfig, config.work);
34+
return benchpressRunner.sample({
35+
id: config.id,
36+
execute: config.work,
37+
prepare: config.prepare,
38+
bindings: [
39+
benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)
40+
]
41+
});
4042
});
4143
}
4244

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var benchpress = require('benchpress/index.js');
1+
var webdriver = require('selenium-webdriver');
22

33
module.exports = {
4-
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors,
4+
verifyNoBrowserErrors: verifyNoBrowserErrors,
55
clickAll: clickAll
66
};
77

@@ -10,3 +10,19 @@ function clickAll(buttonSelectors) {
1010
$(selector).click();
1111
});
1212
}
13+
14+
function verifyNoBrowserErrors() {
15+
// TODO(tbosch): Bug in ChromeDriver: Need to execute at least one command
16+
// so that the browser logs can be read out!
17+
browser.executeScript('1+1');
18+
browser.manage().logs().get('browser').then(function(browserLog) {
19+
var filteredLog = browserLog.filter(function(logEntry) {
20+
return logEntry.level.value > webdriver.logging.Level.WARNING.value;
21+
});
22+
expect(filteredLog.length).toEqual(0);
23+
if (filteredLog.length) {
24+
console.log('browser console errors: ' + require('util').inspect(filteredLog));
25+
}
26+
});
27+
}
28+

modules/angular2/src/di/exceptions.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {ListWrapper, List} from 'angular2/src/facade/collection';
22
import {stringify} from 'angular2/src/facade/lang';
3-
import {Key} from './key';
43

54
function findFirstClosedCycle(keys:List) {
65
var res = [];
@@ -31,14 +30,16 @@ export class ProviderError extends Error {
3130
keys:List;
3231
constructResolvingMessage:Function;
3332
message;
34-
constructor(key:Key, constructResolvingMessage:Function) {
33+
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
34+
constructor(key, constructResolvingMessage:Function) {
3535
super();
3636
this.keys = [key];
3737
this.constructResolvingMessage = constructResolvingMessage;
3838
this.message = this.constructResolvingMessage(this.keys);
3939
}
4040

41-
addKey(key:Key) {
41+
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
42+
addKey(key) {
4243
ListWrapper.push(this.keys, key);
4344
this.message = this.constructResolvingMessage(this.keys);
4445
}
@@ -49,7 +50,8 @@ export class ProviderError extends Error {
4950
}
5051

5152
export class NoProviderError extends ProviderError {
52-
constructor(key:Key) {
53+
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
54+
constructor(key) {
5355
super(key, function (keys:List) {
5456
var first = stringify(ListWrapper.first(keys).token);
5557
return `No provider for ${first}!${constructResolvingPath(keys)}`;
@@ -58,7 +60,8 @@ export class NoProviderError extends ProviderError {
5860
}
5961

6062
export class AsyncBindingError extends ProviderError {
61-
constructor(key:Key) {
63+
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
64+
constructor(key) {
6265
super(key, function (keys:List) {
6366
var first = stringify(ListWrapper.first(keys).token);
6467
return `Cannot instantiate ${first} synchronously. ` +
@@ -68,15 +71,17 @@ export class AsyncBindingError extends ProviderError {
6871
}
6972

7073
export class CyclicDependencyError extends ProviderError {
71-
constructor(key:Key) {
74+
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
75+
constructor(key) {
7276
super(key, function (keys:List) {
7377
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
7478
});
7579
}
7680
}
7781

7882
export class InstantiationError extends ProviderError {
79-
constructor(originalException, key:Key) {
83+
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
84+
constructor(originalException, key) {
8085
super(key, function (keys:List) {
8186
var first = stringify(ListWrapper.first(keys).token);
8287
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.` +

modules/angular2/src/facade/collection.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ class ListWrapper {
9898
l.add(e);
9999
}
100100
static List concat(List a, List b) {
101-
a.addAll(b);
102-
return a;
101+
return []..addAll(a)..addAll(b);
103102
}
104103
static bool isList(l) => l is List;
105104
static void insert(List l, int index, value) {

modules/angular2/src/facade/lang.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ library angular.core.facade.lang;
22

33
export 'dart:core' show Type, RegExp, print;
44
import 'dart:math' as math;
5+
import 'dart:convert' as convert;
56

67
class Math {
78
static final _random = new math.Random();
@@ -176,3 +177,9 @@ bool assertionsEnabled() {
176177
return true;
177178
}
178179
}
180+
181+
// Can't be all uppercase as our transpiler would think it is a special directive...
182+
class Json {
183+
static parse(String s) => convert.JSON.decode(s);
184+
static stringify(data) => convert.JSON.encode(data);
185+
}

modules/angular2/src/facade/lang.es6

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,6 @@ export function print(obj) {
247247
console.log(obj);
248248
}
249249
}
250+
251+
// Can't be all uppercase as our transpiler would think it is a special directive...
252+
export var Json = _global.JSON;

modules/angular2/src/facade/math.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
library angular.core.facade.math;
22

3+
import 'dart:core' show double, num;
34
import 'dart:math' as math;
45

6+
var NaN = double.NAN;
7+
58
class Math {
69
static num pow(num x, num exponent) {
710
return math.pow(x, exponent);
@@ -10,4 +13,8 @@ class Math {
1013
static num min(num a, num b) => math.min(a, b);
1114

1215
static num floor(num a) => a.floor();
16+
17+
static num ceil(num a) => a.ceil();
18+
19+
static num sqrt(num x) => math.sqrt(x);
1320
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import {global} from 'angular2/src/facade/lang';
22

3-
export var Math = global.Math;
3+
export var Math = global.Math;
4+
export var NaN = global.NaN;

0 commit comments

Comments
 (0)