Skip to content

Commit df4ac0d

Browse files
committed
refactor(perf): use webdriver to execute benchmarks
- use performance log of chromedriver / appium to get timeline data for calculating metrics for benchmarks - change all benchmarks to be made of a standalone application and a protractor test that collectes timeline data - fix and simplify benchmarks - add dart2js to build - remove benchpress Closes angular#330
1 parent d642c6a commit df4ac0d

66 files changed

Lines changed: 1152 additions & 991 deletions

Some content is hidden

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

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: node_js
2+
sudo: false
23
node_js:
34
- '0.10'
45
env:

gulpfile.js

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ var clean = require('./tools/build/clean');
88
var deps = require('./tools/build/deps');
99
var transpile = require('./tools/build/transpile');
1010
var html = require('./tools/build/html');
11-
var benchpress = require('./tools/build/benchpress');
1211
var pubspec = require('./tools/build/pubspec');
12+
var pubbuild = require('./tools/build/pubbuild');
1313
var dartanalyzer = require('./tools/build/dartanalyzer');
1414
var jsserve = require('./tools/build/jsserve');
1515
var pubserve = require('./tools/build/pubserve');
16+
1617
var DART_SDK = require('./tools/build/dartdetect')(gulp);
1718
// -----------------------
1819
// configuration
@@ -43,23 +44,18 @@ var _HTLM_DEFAULT_SCRIPTS_JS = [
4344

4445

4546
var CONFIG = {
46-
commands: {
47-
pub: process.platform === 'win32' ? 'pub.bat' : 'pub',
48-
dartanalyzer: process.platform === "win32" ? "dartanalyzer.bat" : "dartanalyzer"
49-
},
5047
dest: {
5148
js: {
5249
all: 'dist/js',
5350
dev: 'dist/js/dev',
54-
prod: 'dist/js/prod'
51+
prod: 'dist/js/prod',
52+
dart2js: 'dist/js/dart2js'
5553
},
5654
dart: 'dist/dart'
5755
},
5856
srcFolderMapping: {
5957
'default': 'lib',
60-
// need a tmp folder as benchpress does not support
61-
// inplace generation of the benchmarks...
62-
'**/benchmark*/**': 'perf_tmp',
58+
'**/benchmark*/**': 'web',
6359
'**/example*/**': 'web'
6460
},
6561
deps: {
@@ -76,12 +72,12 @@ var CONFIG = {
7672
},
7773
transpile: {
7874
src: {
79-
js: ['modules/**/*.js', 'modules/**/*.es6'],
80-
dart: ['modules/**/*.js']
75+
js: ['modules/**/*.js', 'modules/**/*.es6', '!modules/**/perf/**/*'],
76+
dart: ['modules/**/*.js', '!modules/**/perf/**/*']
8177
},
8278
copy: {
83-
js: ['modules/**/*.es5'],
84-
dart: ['modules/**/*.dart']
79+
js: ['modules/**/*.es5', '!modules/**/perf/**/*'],
80+
dart: ['modules/**/*.dart', '!modules/**/perf/**/*']
8581
},
8682
options: {
8783
js: {
@@ -122,14 +118,6 @@ var CONFIG = {
122118
}
123119
}
124120
},
125-
benchpress: {
126-
configFile: {
127-
content: 'module.exports=function(){};\n',
128-
name: 'bp.conf.js'
129-
},
130-
mainHtmls: '*/perf_tmp/**/main.html',
131-
outputFolderName: 'web'
132-
},
133121
pubspec: {
134122
src: 'modules/*/pubspec.yaml'
135123
}
@@ -213,31 +201,6 @@ gulp.task('build/html.dart', html(gulp, gulpPlugins, {
213201
scriptsPerFolder: CONFIG.html.scriptsPerFolder.dart
214202
}));
215203

216-
// ------------
217-
// benchpress
218-
219-
gulp.task('build/benchpress.js.dev', benchpress(gulp, gulpPlugins, {
220-
mainHtmls: CONFIG.benchpress.mainHtmls,
221-
configFile: CONFIG.benchpress.configFile,
222-
buildDir: CONFIG.dest.js.dev,
223-
outputFolderName: CONFIG.benchpress.outputFolderName
224-
}));
225-
226-
gulp.task('build/benchpress.js.prod', benchpress(gulp, gulpPlugins, {
227-
mainHtmls: CONFIG.benchpress.mainHtmls,
228-
configFile: CONFIG.benchpress.configFile,
229-
buildDir: CONFIG.dest.js.prod,
230-
outputFolderName: CONFIG.benchpress.outputFolderName
231-
}));
232-
233-
gulp.task('build/benchpress.dart', benchpress(gulp, gulpPlugins, {
234-
mainHtmls: CONFIG.benchpress.mainHtmls,
235-
configFile: CONFIG.benchpress.configFile,
236-
buildDir: CONFIG.dest.dart,
237-
outputFolderName: CONFIG.benchpress.outputFolderName
238-
}));
239-
240-
241204
// ------------
242205
// pubspec
243206

@@ -248,22 +211,38 @@ gulp.task('build/pubspec.dart', pubspec(gulp, gulpPlugins, {
248211
}));
249212

250213
// ------------
251-
// pubspec
214+
// dartanalyzer
252215

253216
gulp.task('build/analyze.dart', dartanalyzer(gulp, gulpPlugins, {
254217
dest: CONFIG.dest.dart,
255218
command: DART_SDK.ANALYZER,
256219
srcFolderMapping: CONFIG.srcFolderMapping
257220
}));
258221

222+
// ------------
223+
// pubbuild
224+
225+
gulp.task('build/pubbuild.dart', pubbuild(gulp, gulpPlugins, {
226+
src: CONFIG.dest.dart,
227+
dest: CONFIG.dest.js.dart2js,
228+
command: DART_SDK.PUB
229+
}));
230+
259231
// ------------------
260232
// web servers
261233
gulp.task('serve.js.dev', jsserve(gulp, gulpPlugins, {
262-
path: CONFIG.dest.js.dev
234+
path: CONFIG.dest.js.dev,
235+
port: 8000
263236
}));
264237

265238
gulp.task('serve.js.prod', jsserve(gulp, gulpPlugins, {
266-
path: CONFIG.dest.js.prod
239+
path: CONFIG.dest.js.prod,
240+
port: 8001
241+
}));
242+
243+
gulp.task('serve.js.dart2js', jsserve(gulp, gulpPlugins, {
244+
path: CONFIG.dest.js.dart2js,
245+
port: 8002
267246
}));
268247

269248
gulp.task('serve/examples.dart', pubserve(gulp, gulpPlugins, {
@@ -343,22 +322,20 @@ gulp.task('build.dart', function() {
343322
return runSequence(
344323
['build/transpile.dart', 'build/html.dart'],
345324
'build/pubspec.dart',
346-
'build/benchpress.dart',
325+
'build/pubbuild.dart',
347326
'build/analyze.dart'
348327
);
349328
});
350329

351330
gulp.task('build.js.dev', function() {
352331
return runSequence(
353-
['build/deps.js.dev', 'build/transpile.js.dev', 'build/html.js.dev'],
354-
'build/benchpress.js.dev'
332+
['build/deps.js.dev', 'build/transpile.js.dev', 'build/html.js.dev']
355333
);
356334
});
357335

358336
gulp.task('build.js.prod', function() {
359337
return runSequence(
360-
['build/deps.js.prod', 'build/transpile.js.prod', 'build/html.js.prod'],
361-
'build/benchpress.js.prod'
338+
['build/deps.js.prod', 'build/transpile.js.prod', 'build/html.js.prod']
362339
);
363340
});
364341

modules/benchmarks/pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ dependencies:
1212
path: ../core
1313
change_detection:
1414
path: ../change_detection
15-
benchpress:
16-
path: ../benchpress
1715
browser: '>=0.10.0 <0.11.0'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html>
3+
<body>
4+
5+
<button id="ng2DetectChanges">Ng2 detect changes</button>
6+
<button id="baselineDetectChanges">baseline detect changes</button>
7+
8+
$SCRIPTS$
9+
10+
</body>

modules/benchmarks/src/change_detection/change_detection_benchmark.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Parser} from 'change_detection/parser/parser';
33
import {Lexer} from 'change_detection/parser/lexer';
44
import {reflector} from 'reflection/reflection';
55
import {isPresent} from 'facade/lang';
6-
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
6+
import {document, DOM} from 'facade/dom';
77

88
import {
99
ChangeDetector,
@@ -12,7 +12,7 @@ import {
1212
} from 'change_detection/change_detector';
1313

1414

15-
var ITERATIONS = 200000;
15+
var ITERATIONS = 500000;
1616

1717
class Obj {
1818
field0;
@@ -155,28 +155,25 @@ function setUpChangeDetection() {
155155

156156
export function main () {
157157
setUpReflector();
158-
159-
benchmark(`Baseline`, function () {
160-
var head = setUpBaseline();
161-
162-
benchmarkStep('run', function () {
163-
var current = head;
164-
while (isPresent(current)) {
165-
if (current.getter(current.obj) !== current.previousValue) {
166-
throw "should not happen";
167-
}
168-
current = current.next;
158+
var baselineHead = setUpBaseline();
159+
var ng2ChangeDetector = setUpChangeDetection();
160+
161+
function baselineDetectChanges(_) {
162+
var current = baselineHead;
163+
while (isPresent(current)) {
164+
if (current.getter(current.obj) !== current.previousValue) {
165+
throw "should not happen";
169166
}
170-
});
171-
});
167+
current = current.next;
168+
}
169+
}
172170

173-
benchmark(`Change Detection`, function() {
174-
var cd = setUpChangeDetection();
171+
function ng2DetectChanges(_) {
172+
ng2ChangeDetector.detectChanges();
173+
}
175174

176-
benchmarkStep('run', function() {
177-
cd.detectChanges();
178-
});
179-
});
175+
DOM.on(DOM.querySelector(document, '#ng2DetectChanges'), 'click', ng2DetectChanges);
176+
DOM.on(DOM.querySelector(document, '#baselineDetectChanges'), 'click', baselineDetectChanges);
180177
}
181178

182179

modules/benchmarks/src/change_detection/main.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

modules/benchmarks/src/change_detection/main.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

modules/benchmarks/src/compiler/main.html renamed to modules/benchmarks/src/compiler/compiler_benchmark.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
$SCRIPTS$
1+
<!doctype html>
2+
<html>
3+
<body>
4+
5+
<button id="compileWithBindings">Compile template with bindings</button>
6+
<button id="compileNoBindings">Compile template without bindings</button>
27

38
<template id="templateNoBindings">
49
<div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4">
@@ -30,3 +35,8 @@
3035
</div>
3136
</div>
3237
</template>
38+
39+
$SCRIPTS$
40+
41+
</body>
42+
</html>

0 commit comments

Comments
 (0)