|
1 | 1 | "use strict"; |
2 | | -var util = require('../../../../tools/perf/util.js'); |
| 2 | +var benchpress = require('../../../../tools/benchpress/benchpress.js'); |
3 | 3 |
|
4 | 4 | describe('ng2 di benchmark', function () { |
5 | 5 |
|
6 | 6 | var URL = 'benchmarks/web/di/di_benchmark.html'; |
7 | 7 |
|
8 | | - afterEach(util.verifyNoErrors); |
| 8 | + afterEach(benchpress.verifyNoBrowserErrors); |
9 | 9 |
|
10 | 10 | it('should log the stats for getByToken', function() { |
11 | 11 | browser.get(URL); |
12 | | - util.runClickBenchmark({ |
| 12 | + runClickTimeBenchmark({ |
13 | 13 | buttons: ['#getByToken'], |
14 | | - name: browser.params.lang+'.ng2.di.getByToken' |
| 14 | + logId: 'ng2.di.getByToken' |
15 | 15 | }); |
16 | 16 | }); |
17 | 17 |
|
18 | 18 | it('should log the stats for getByKey', function() { |
19 | 19 | browser.get(URL); |
20 | | - util.runClickBenchmark({ |
| 20 | + runClickTimeBenchmark({ |
21 | 21 | buttons: ['#getByKey'], |
22 | | - name: browser.params.lang+'.ng2.di.getByKey' |
| 22 | + logId: 'ng2.di.getByKey' |
23 | 23 | }); |
24 | 24 | }); |
25 | 25 |
|
26 | 26 | it('should log the stats for getChild', function() { |
27 | 27 | browser.get(URL); |
28 | | - util.runClickBenchmark({ |
| 28 | + runClickTimeBenchmark({ |
29 | 29 | buttons: ['#getChild'], |
30 | | - name: browser.params.lang+'.ng2.di.getChild' |
| 30 | + logId: 'ng2.di.getChild' |
31 | 31 | }); |
32 | 32 | }); |
33 | 33 |
|
34 | 34 | it('should log the stats for instantiate', function() { |
35 | 35 | browser.get(URL); |
36 | | - util.runClickBenchmark({ |
| 36 | + runClickTimeBenchmark({ |
37 | 37 | buttons: ['#instantiate'], |
38 | | - name: browser.params.lang+'.ng2.di.instantiate' |
| 38 | + logId: 'ng2.di.instantiate' |
39 | 39 | }); |
40 | 40 | }); |
41 | 41 |
|
42 | 42 | }); |
| 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 | +} |
0 commit comments