Skip to content

Commit 6f30312

Browse files
committed
refactor(perf): introduce benchpress2
Major changes: - make API more reusable - format output nicely - only force gc if needed Regarding forcing gc: Forcing gc can change script execution time. We now don't force gc at first and ignore results where gc happens during script execution. When we ignored too many results, we switch to forcing gc. Closes angular#339
1 parent 53906e4 commit 6f30312

File tree

16 files changed

+572
-285
lines changed

16 files changed

+572
-285
lines changed
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng2 change detection benchmark', function () {
55

66
var URL = 'benchmarks/web/change_detection/change_detection_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log ng stats', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#ng2DetectChanges'],
14-
name: browser.params.lang+'.ng2.changeDetection'
14+
logId: 'ng2.changeDetection'
1515
});
1616
});
1717

1818
it('should log baseline stats', function() {
1919
browser.get(URL);
20-
util.runClickBenchmark({
20+
runClickTimeBenchmark({
2121
buttons: ['#baselineDetectChanges'],
22-
name: browser.params.lang+'.baseline.changeDetection'
22+
logId: 'baseline.changeDetection'
2323
});
2424
});
2525

2626
});
27+
28+
function runClickTimeBenchmark(config) {
29+
var buttons = config.buttons.map(function(selector) {
30+
return $(selector);
31+
});
32+
var timeParams = browser.params.timeBenchmark;
33+
benchpress.runTimeBenchmark({
34+
sampleSize: timeParams.sampleSize,
35+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
36+
timeout: timeParams.timeout,
37+
metrics: timeParams.metrics,
38+
logId: browser.params.lang+'.'+config.logId
39+
}, function() {
40+
buttons.forEach(function(button) {
41+
button.click();
42+
});
43+
});
44+
}
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng2 compiler benchmark', function () {
55

66
var URL = 'benchmarks/web/compiler/compiler_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log withBindings stats', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#compileWithBindings'],
14-
name: browser.params.lang+'.ng2.compile.withBindings'
14+
logId: 'ng2.compile.withBindings'
1515
});
1616
});
1717

1818
it('should log noBindings stats', function() {
1919
browser.get(URL);
20-
util.runClickBenchmark({
20+
runClickTimeBenchmark({
2121
buttons: ['#compileNoBindings'],
22-
name: browser.params.lang+'.ng2.compile.noBindings'
22+
logId: 'ng2.compile.noBindings'
2323
});
2424
});
2525

2626
});
27+
28+
function runClickTimeBenchmark(config) {
29+
var buttons = config.buttons.map(function(selector) {
30+
return $(selector);
31+
});
32+
var timeParams = browser.params.timeBenchmark;
33+
benchpress.runTimeBenchmark({
34+
sampleSize: timeParams.sampleSize,
35+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
36+
timeout: timeParams.timeout,
37+
metrics: timeParams.metrics,
38+
logId: browser.params.lang+'.'+config.logId
39+
}, function() {
40+
buttons.forEach(function(button) {
41+
button.click();
42+
});
43+
});
44+
}
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,60 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng2 di benchmark', function () {
55

66
var URL = 'benchmarks/web/di/di_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log the stats for getByToken', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#getByToken'],
14-
name: browser.params.lang+'.ng2.di.getByToken'
14+
logId: 'ng2.di.getByToken'
1515
});
1616
});
1717

1818
it('should log the stats for getByKey', function() {
1919
browser.get(URL);
20-
util.runClickBenchmark({
20+
runClickTimeBenchmark({
2121
buttons: ['#getByKey'],
22-
name: browser.params.lang+'.ng2.di.getByKey'
22+
logId: 'ng2.di.getByKey'
2323
});
2424
});
2525

2626
it('should log the stats for getChild', function() {
2727
browser.get(URL);
28-
util.runClickBenchmark({
28+
runClickTimeBenchmark({
2929
buttons: ['#getChild'],
30-
name: browser.params.lang+'.ng2.di.getChild'
30+
logId: 'ng2.di.getChild'
3131
});
3232
});
3333

3434
it('should log the stats for instantiate', function() {
3535
browser.get(URL);
36-
util.runClickBenchmark({
36+
runClickTimeBenchmark({
3737
buttons: ['#instantiate'],
38-
name: browser.params.lang+'.ng2.di.instantiate'
38+
logId: 'ng2.di.instantiate'
3939
});
4040
});
4141

4242
});
43+
44+
function runClickTimeBenchmark(config) {
45+
var buttons = config.buttons.map(function(selector) {
46+
return $(selector);
47+
});
48+
var timeParams = browser.params.timeBenchmark;
49+
benchpress.runTimeBenchmark({
50+
sampleSize: timeParams.sampleSize,
51+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
52+
timeout: timeParams.timeout,
53+
metrics: timeParams.metrics,
54+
logId: browser.params.lang+'.'+config.logId
55+
}, function() {
56+
buttons.forEach(function(button) {
57+
button.click();
58+
});
59+
});
60+
}
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng2 element injector benchmark', function () {
55

66
var URL = 'benchmarks/web/element_injector/element_injector_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log the stats for instantiate', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#instantiate'],
14-
name: browser.params.lang+'.ng2.elementInjector.instantiate'
14+
logId: 'ng2.elementInjector.instantiate'
1515
});
1616
});
1717

1818
it('should log the stats for instantiateDirectives', function() {
1919
browser.get(URL);
20-
util.runClickBenchmark({
20+
runClickTimeBenchmark({
2121
buttons: ['#instantiateDirectives'],
22-
name: browser.params.lang+'.ng2.elementInjector.instantiateDirectives'
22+
logId: 'ng2.elementInjector.instantiateDirectives'
2323
});
2424
});
2525

2626
});
27+
28+
function runClickTimeBenchmark(config) {
29+
var buttons = config.buttons.map(function(selector) {
30+
return $(selector);
31+
});
32+
var timeParams = browser.params.timeBenchmark;
33+
benchpress.runTimeBenchmark({
34+
sampleSize: timeParams.sampleSize,
35+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
36+
timeout: timeParams.timeout,
37+
metrics: timeParams.metrics,
38+
logId: browser.params.lang+'.'+config.logId
39+
}, function() {
40+
buttons.forEach(function(button) {
41+
button.click();
42+
});
43+
});
44+
}
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng2 tree benchmark', function () {
55

66
var URL = 'benchmarks/web/tree/tree_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log the ng stats', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
14-
name: browser.params.lang+'.ng2.tree'
14+
logId: 'ng2.tree'
1515
});
1616
});
1717

1818
it('should log the baseline stats', function() {
1919
browser.get(URL);
20-
util.runClickBenchmark({
20+
runClickTimeBenchmark({
2121
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
22-
name: browser.params.lang+'.baseline.tree'
22+
logId: 'baseline.tree'
2323
});
2424
});
2525

2626
});
27+
28+
function runClickTimeBenchmark(config) {
29+
var buttons = config.buttons.map(function(selector) {
30+
return $(selector);
31+
});
32+
var timeParams = browser.params.timeBenchmark;
33+
benchpress.runTimeBenchmark({
34+
sampleSize: timeParams.sampleSize,
35+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
36+
timeout: timeParams.timeout,
37+
metrics: timeParams.metrics,
38+
logId: browser.params.lang+'.'+config.logId
39+
}, function() {
40+
buttons.forEach(function(button) {
41+
button.click();
42+
});
43+
});
44+
}
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng1.x compiler benchmark', function () {
55

66
var URL = 'benchmarks_external/web/compiler/compiler_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log withBinding stats', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#compileWithBindings'],
14-
name: browser.params.lang+'.ng1.compile.withBindings'
14+
logId: 'ng1.compile.withBindings'
1515
});
1616
});
1717

1818
it('should log noBindings stats', function() {
19-
util.runClickBenchmark({
19+
browser.get(URL);
20+
runClickTimeBenchmark({
2021
buttons: ['#compileNoBindings'],
21-
name: browser.params.lang+'.ng1.compile.noBindings'
22+
logId: 'ng1.compile.noBindings'
2223
});
2324
});
2425

2526
});
27+
28+
function runClickTimeBenchmark(config) {
29+
var buttons = config.buttons.map(function(selector) {
30+
return $(selector);
31+
});
32+
var timeParams = browser.params.timeBenchmark;
33+
benchpress.runTimeBenchmark({
34+
sampleSize: timeParams.sampleSize,
35+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
36+
timeout: timeParams.timeout,
37+
metrics: timeParams.metrics,
38+
logId: browser.params.lang+'.'+config.logId
39+
}, function() {
40+
buttons.forEach(function(button) {
41+
button.click();
42+
});
43+
});
44+
}
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
"use strict";
2-
var util = require('../../../../tools/perf/util.js');
2+
var benchpress = require('../../../../tools/benchpress/benchpress.js');
33

44
describe('ng1.x tree benchmark', function () {
55

66
var URL = 'benchmarks_external/web/tree/tree_benchmark.html';
77

8-
afterEach(util.verifyNoErrors);
8+
afterEach(benchpress.verifyNoBrowserErrors);
99

1010
it('should log the stats', function() {
1111
browser.get(URL);
12-
util.runClickBenchmark({
12+
runClickTimeBenchmark({
1313
buttons: ['#destroyDom', '#createDom'],
14-
name: browser.params.lang+'.ng1.tree'
14+
logId: 'ng1.tree'
1515
});
1616
});
1717

1818
});
19+
20+
function runClickTimeBenchmark(config) {
21+
var buttons = config.buttons.map(function(selector) {
22+
return $(selector);
23+
});
24+
var timeParams = browser.params.timeBenchmark;
25+
benchpress.runTimeBenchmark({
26+
sampleSize: timeParams.sampleSize,
27+
targetCoefficientOfVariation: timeParams.targetCoefficientOfVariation,
28+
timeout: timeParams.timeout,
29+
metrics: timeParams.metrics,
30+
logId: browser.params.lang+'.'+config.logId
31+
}, function() {
32+
buttons.forEach(function(button) {
33+
button.click();
34+
});
35+
});
36+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"gulp-webserver": "^0.8.7",
4444
"angular": "1.3.5",
4545
"minimatch": "^2.0.1",
46-
"lodash": "^2.4.1"
46+
"lodash": "^2.4.1",
47+
"sprintf-js": "1.0.*"
4748
}
4849
}

0 commit comments

Comments
 (0)