From d02c0accbb877bc09095b628f40d18562af748f3 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 9 Jan 2015 18:00:04 -0800 Subject: [PATCH] refactor(benchmarks): add cloud reporter, add params - adds console and cloud reporter (via Google BigQuery). - makes parameters of tests explicit and modifiable. - removes `detect` and `ignoreGc` mode from benchpress as these can result in unstable numbers. --- .gitignore | 2 + gulpfile.js | 38 ++- .../e2e_test/change_detection_perf.es6 | 36 +-- .../e2e_test/change_detection_spec.es6 | 12 +- modules/benchmarks/e2e_test/compiler_perf.es6 | 36 +-- modules/benchmarks/e2e_test/compiler_spec.es6 | 13 +- modules/benchmarks/e2e_test/di_perf.es6 | 54 ++-- modules/benchmarks/e2e_test/di_spec.es6 | 12 +- .../e2e_test/element_injector_perf.es6 | 36 +-- .../e2e_test/element_injector_spec.es6 | 12 +- modules/benchmarks/e2e_test/selector_perf.es6 | 41 +++ modules/benchmarks/e2e_test/selector_spec.es6 | 14 + modules/benchmarks/e2e_test/tree_perf.es6 | 36 +-- modules/benchmarks/e2e_test/tree_spec.es6 | 12 +- modules/benchmarks/pubspec.yaml | 2 + .../change_detection_benchmark.html | 13 +- .../change_detection_benchmark.js | 28 +- .../src/compiler/compiler_benchmark.html | 15 +- .../src/compiler/compiler_benchmark.js | 17 +- .../src/compiler/selector_benchmark.html | 11 + .../src/compiler/selector_benchmark.js | 31 +-- modules/benchmarks/src/di/di_benchmark.html | 19 +- modules/benchmarks/src/di/di_benchmark.js | 28 +- .../element_injector_benchmark.html | 15 +- .../element_injector_benchmark.js | 17 +- .../benchmarks/src/tree/tree_benchmark.html | 8 + modules/benchmarks/src/tree/tree_benchmark.js | 47 ++-- .../e2e_test/compiler_perf.es6 | 36 +-- .../e2e_test/compiler_spec.es6 | 12 +- .../e2e_test/tree_perf.es6 | 27 +- .../e2e_test/tree_spec.es6 | 12 +- modules/benchmarks_external/pubspec.yaml | 2 + .../src/compiler/compiler_benchmark.dart | 17 +- .../src/compiler/compiler_benchmark.es6 | 15 +- .../src/compiler/compiler_benchmark.html | 15 +- .../src/tree/tree_benchmark.dart | 15 +- .../src/tree/tree_benchmark.es6 | 14 +- .../src/tree/tree_benchmark.html | 8 + modules/e2e_test_lib/e2e_test/perf_util.es6 | 25 ++ modules/e2e_test_lib/e2e_test/test_util.es6 | 12 + modules/e2e_test_lib/pubspec.yaml | 7 + modules/e2e_test_lib/src/benchmark_util.js | 17 ++ package.json | 4 +- perf-cloud-secret.template.js | 11 + protractor-perf-shared.js | 23 +- tools/benchpress/src/benchmark.es6 | 259 ++++++++---------- tools/benchpress/src/cloud_reporter.es6 | 224 +++++++++++++++ tools/benchpress/src/console_reporter.es6 | 77 ++++++ tools/benchpress/src/reporter.es6 | 32 --- tools/benchpress/src/statistics.es6 | 37 +++ tools/benchpress/src/stats.es6 | 59 ---- tools/build/{ => snippets}/runtime_paths.js | 1 + tools/build/snippets/url_params_to_form.js | 14 + 53 files changed, 981 insertions(+), 599 deletions(-) create mode 100644 modules/benchmarks/e2e_test/selector_perf.es6 create mode 100644 modules/benchmarks/e2e_test/selector_spec.es6 create mode 100644 modules/e2e_test_lib/e2e_test/perf_util.es6 create mode 100644 modules/e2e_test_lib/e2e_test/test_util.es6 create mode 100644 modules/e2e_test_lib/pubspec.yaml create mode 100644 modules/e2e_test_lib/src/benchmark_util.js create mode 100644 perf-cloud-secret.template.js create mode 100644 tools/benchpress/src/cloud_reporter.es6 create mode 100644 tools/benchpress/src/console_reporter.es6 delete mode 100644 tools/benchpress/src/reporter.es6 create mode 100644 tools/benchpress/src/statistics.es6 delete mode 100644 tools/benchpress/src/stats.es6 rename tools/build/{ => snippets}/runtime_paths.js (92%) create mode 100644 tools/build/snippets/url_params_to_form.js diff --git a/.gitignore b/.gitignore index 671e6e8b9b..5e26662be8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,7 @@ pubspec.lock .idea/ *.swo +# Don't check in secret files +*secret.js /docs/bower_components/ diff --git a/gulpfile.js b/gulpfile.js index a8c2ea0578..f3f33d7e3f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -54,6 +54,10 @@ var _HTLM_DEFAULT_SCRIPTS_JS = [ } ]; +var _HTML_DEFAULT_SCRIPTS_DART = [ + {src: '$MODULENAME_WITHOUT_PATH$.dart', mimeType: 'application/dart'}, + {src: 'packages/browser/dart.js', mimeType: 'text/javascript'} +]; var CONFIG = { dest: { @@ -72,7 +76,8 @@ var CONFIG = { }, srcFolderMapping: { 'default': 'lib', - '**/benchmark*/**': 'web', + '**/benchmarks/**': 'web', + '**/benchmarks_external/**': 'web', '**/example*/**': 'web' }, deps: { @@ -83,8 +88,12 @@ var CONFIG = { "node_modules/systemjs/lib/extension-register.js", "node_modules/zone.js/zone.js", "node_modules/zone.js/long-stack-trace-zone.js", - "tools/build/runtime_paths.js", + "tools/build/snippets/runtime_paths.js", + "tools/build/snippets/url_params_to_form.js", "node_modules/angular/angular.js" + ], + dart: [ + "tools/build/snippets/url_params_to_form.js" ] }, transpile: { @@ -133,14 +142,22 @@ var CONFIG = { scriptsPerFolder: { js: { default: _HTLM_DEFAULT_SCRIPTS_JS, + 'benchmarks/**': + [ + { src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' } + ].concat(_HTLM_DEFAULT_SCRIPTS_JS), 'benchmarks_external/**': - [{ src: '/deps/angular.js', mimeType: 'text/javascript' }].concat(_HTLM_DEFAULT_SCRIPTS_JS) + [ + { src: '/deps/angular.js', mimeType: 'text/javascript' }, + { src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' } + ].concat(_HTLM_DEFAULT_SCRIPTS_JS) }, dart: { - default: [ - {src: '$MODULENAME_WITHOUT_PATH$.dart', mimeType: 'application/dart'}, - {src: 'packages/browser/dart.js', mimeType: 'text/javascript'} - ] + default: _HTML_DEFAULT_SCRIPTS_DART, + 'benchmarks*/**': + [ + { src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' } + ].concat(_HTML_DEFAULT_SCRIPTS_DART) } } }, @@ -178,6 +195,11 @@ gulp.task('build/deps.js.prod', deps(gulp, gulpPlugins, { dest: CONFIG.dest.js.prod })); +gulp.task('build/deps.js.dart2js', deps(gulp, gulpPlugins, { + src: CONFIG.deps.dart, + dest: CONFIG.dest.js.dart2js +})); + // ------------ // transpile @@ -373,7 +395,7 @@ gulp.task('docs/serve', function() { // orchestrated targets gulp.task('build.dart', function() { return runSequence( - ['build/transpile.dart', 'build/html.dart'], + ['build/deps.js.dart2js', 'build/transpile.dart', 'build/html.dart'], 'build/pubspec.dart', 'build/pubbuild.dart', 'build/analyze.dart' diff --git a/modules/benchmarks/e2e_test/change_detection_perf.es6 b/modules/benchmarks/e2e_test/change_detection_perf.es6 index 5b9040e8be..f26aa0a02c 100644 --- a/modules/benchmarks/e2e_test/change_detection_perf.es6 +++ b/modules/benchmarks/e2e_test/change_detection_perf.es6 @@ -1,39 +1,31 @@ -"use strict"; -var benchpress = require('../../../tools/benchpress/index.js'); +var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util'); describe('ng2 change detection benchmark', function () { var URL = 'benchmarks/web/change_detection/change_detection_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(perfUtil.verifyNoBrowserErrors); it('should log ng stats', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#ng2DetectChanges'], - logId: 'ng2.changeDetection' + id: 'ng2.changeDetection', + params: [{ + name: 'iterations', value: 500000 + }] }); }); it('should log baseline stats', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#baselineDetectChanges'], - logId: 'baseline.changeDetection' + id: 'baseline.changeDetection', + params: [{ + name: 'iterations', value: 500000 + }] }); }); }); - -function runClickBenchmark(config) { - var buttons = config.buttons.map(function(selector) { - return $(selector); - }); - var params = Object.create(browser.params.benchmark); - params.logId = browser.params.lang+'.'+config.logId; - benchpress.runBenchmark(params, function() { - buttons.forEach(function(button) { - button.click(); - }); - }); -} diff --git a/modules/benchmarks/e2e_test/change_detection_spec.es6 b/modules/benchmarks/e2e_test/change_detection_spec.es6 index fcd7b2a10d..93a72e5806 100644 --- a/modules/benchmarks/e2e_test/change_detection_spec.es6 +++ b/modules/benchmarks/e2e_test/change_detection_spec.es6 @@ -1,20 +1,14 @@ -var benchpress = require('../../../tools/benchpress/index.js'); +var testUtil = require('../../e2e_test_lib/e2e_test/test_util'); describe('ng2 change detection benchmark', function () { var URL = 'benchmarks/web/change_detection/change_detection_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(testUtil.verifyNoBrowserErrors); it('should not throw errors', function() { browser.get(URL); - clickAll(['#ng2DetectChanges', '#baselineDetectChanges']); + testUtil.clickAll(['#ng2DetectChanges', '#baselineDetectChanges']); }); }); - -function clickAll(buttonSelectors) { - buttonSelectors.forEach(function(selector) { - $(selector).click(); - }); -} diff --git a/modules/benchmarks/e2e_test/compiler_perf.es6 b/modules/benchmarks/e2e_test/compiler_perf.es6 index 396645f47b..894f862c54 100644 --- a/modules/benchmarks/e2e_test/compiler_perf.es6 +++ b/modules/benchmarks/e2e_test/compiler_perf.es6 @@ -1,39 +1,31 @@ -"use strict"; -var benchpress = require('../../../tools/benchpress/index.js'); +var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util'); describe('ng2 compiler benchmark', function () { var URL = 'benchmarks/web/compiler/compiler_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(perfUtil.verifyNoBrowserErrors); it('should log withBindings stats', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#compileWithBindings'], - logId: 'ng2.compile.withBindings' + id: 'ng2.compile.withBindings', + params: [{ + name: 'elementCount', selector: '#elementCount', value: 150 + }] }); }); it('should log noBindings stats', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#compileNoBindings'], - logId: 'ng2.compile.noBindings' + id: 'ng2.compile.noBindings', + params: [{ + name: 'elementCount', value: 150 + }] }); }); }); - -function runClickBenchmark(config) { - var buttons = config.buttons.map(function(selector) { - return $(selector); - }); - var params = Object.create(browser.params.benchmark); - params.logId = browser.params.lang+'.'+config.logId; - benchpress.runBenchmark(params, function() { - buttons.forEach(function(button) { - button.click(); - }); - }); -} diff --git a/modules/benchmarks/e2e_test/compiler_spec.es6 b/modules/benchmarks/e2e_test/compiler_spec.es6 index aef09eb623..955a70ae4c 100644 --- a/modules/benchmarks/e2e_test/compiler_spec.es6 +++ b/modules/benchmarks/e2e_test/compiler_spec.es6 @@ -1,21 +1,14 @@ -"use strict"; -var benchpress = require('../../../tools/benchpress/index.js'); +var testUtil = require('../../e2e_test_lib/e2e_test/test_util'); describe('ng2 compiler benchmark', function () { var URL = 'benchmarks/web/compiler/compiler_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(testUtil.verifyNoBrowserErrors); it('should not throw errors', function() { browser.get(URL); - clickAll(['#compileWithBindings', '#compileNoBindings']); + testUtil.clickAll(['#compileWithBindings', '#compileNoBindings']); }); }); - -function clickAll(buttonSelectors) { - buttonSelectors.forEach(function(selector) { - $(selector).click(); - }); -} diff --git a/modules/benchmarks/e2e_test/di_perf.es6 b/modules/benchmarks/e2e_test/di_perf.es6 index 380717b278..0f4b04bd9e 100644 --- a/modules/benchmarks/e2e_test/di_perf.es6 +++ b/modules/benchmarks/e2e_test/di_perf.es6 @@ -1,55 +1,53 @@ -"use strict"; -var benchpress = require('../../../tools/benchpress/index.js'); +var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util'); describe('ng2 di benchmark', function () { var URL = 'benchmarks/web/di/di_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(perfUtil.verifyNoBrowserErrors); it('should log the stats for getByToken', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#getByToken'], - logId: 'ng2.di.getByToken' + id: 'ng2.di.getByToken', + params: [{ + name: 'iterations', value: 20000 + }] }); }); it('should log the stats for getByKey', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#getByKey'], - logId: 'ng2.di.getByKey' + id: 'ng2.di.getByKey', + params: [{ + name: 'iterations', value: 20000 + }] }); }); it('should log the stats for getChild', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#getChild'], - logId: 'ng2.di.getChild' + id: 'ng2.di.getChild', + params: [{ + name: 'iterations', value: 20000 + }] }); }); it('should log the stats for instantiate', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#instantiate'], - logId: 'ng2.di.instantiate' + id: 'ng2.di.instantiate', + params: [{ + name: 'iterations', value: 10000 + }] }); }); }); - -function runClickBenchmark(config) { - var buttons = config.buttons.map(function(selector) { - return $(selector); - }); - var params = Object.create(browser.params.benchmark); - params.logId = browser.params.lang+'.'+config.logId; - benchpress.runBenchmark(params, function() { - buttons.forEach(function(button) { - button.click(); - }); - }); -} diff --git a/modules/benchmarks/e2e_test/di_spec.es6 b/modules/benchmarks/e2e_test/di_spec.es6 index 3fd6a7b800..d7f9a24c93 100644 --- a/modules/benchmarks/e2e_test/di_spec.es6 +++ b/modules/benchmarks/e2e_test/di_spec.es6 @@ -1,20 +1,14 @@ -var benchpress = require('../../../tools/benchpress/index.js'); +var testUtil = require('../../e2e_test_lib/e2e_test/test_util'); describe('ng2 di benchmark', function () { var URL = 'benchmarks/web/di/di_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(testUtil.verifyNoBrowserErrors); it('should not throw errors', function() { browser.get(URL); - clickAll(['#getByToken', '#getByKey', '#getChild', '#instantiate']); + testUtil.clickAll(['#getByToken', '#getByKey', '#getChild', '#instantiate']); }); }); - -function clickAll(buttonSelectors) { - buttonSelectors.forEach(function(selector) { - $(selector).click(); - }); -} diff --git a/modules/benchmarks/e2e_test/element_injector_perf.es6 b/modules/benchmarks/e2e_test/element_injector_perf.es6 index 67a3e5f5b4..b36f1de409 100644 --- a/modules/benchmarks/e2e_test/element_injector_perf.es6 +++ b/modules/benchmarks/e2e_test/element_injector_perf.es6 @@ -1,39 +1,31 @@ -"use strict"; -var benchpress = require('../../../tools/benchpress/index.js'); +var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util'); describe('ng2 element injector benchmark', function () { var URL = 'benchmarks/web/element_injector/element_injector_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(perfUtil.verifyNoBrowserErrors); it('should log the stats for instantiate', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#instantiate'], - logId: 'ng2.elementInjector.instantiate' + id: 'ng2.elementInjector.instantiate', + params: [{ + name: 'iterations', value: 20000 + }] }); }); it('should log the stats for instantiateDirectives', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#instantiateDirectives'], - logId: 'ng2.elementInjector.instantiateDirectives' + id: 'ng2.elementInjector.instantiateDirectives', + params: [{ + name: 'iterations', value: 20000 + }] }); }); }); - -function runClickBenchmark(config) { - var buttons = config.buttons.map(function(selector) { - return $(selector); - }); - var params = Object.create(browser.params.benchmark); - params.logId = browser.params.lang+'.'+config.logId; - benchpress.runBenchmark(params, function() { - buttons.forEach(function(button) { - button.click(); - }); - }); -} diff --git a/modules/benchmarks/e2e_test/element_injector_spec.es6 b/modules/benchmarks/e2e_test/element_injector_spec.es6 index 272928e996..90e04ac590 100644 --- a/modules/benchmarks/e2e_test/element_injector_spec.es6 +++ b/modules/benchmarks/e2e_test/element_injector_spec.es6 @@ -1,20 +1,14 @@ -var benchpress = require('../../../tools/benchpress/index.js'); +var testUtil = require('../../e2e_test_lib/e2e_test/test_util'); describe('ng2 element injector benchmark', function () { var URL = 'benchmarks/web/element_injector/element_injector_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(testUtil.verifyNoBrowserErrors); it('should not throw errors', function() { browser.get(URL); - clickAll(['#instantiate', '#instantiateDirectives']); + testUtil.clickAll(['#instantiate', '#instantiateDirectives']); }); }); - -function clickAll(buttonSelectors) { - buttonSelectors.forEach(function(selector) { - $(selector).click(); - }); -} diff --git a/modules/benchmarks/e2e_test/selector_perf.es6 b/modules/benchmarks/e2e_test/selector_perf.es6 new file mode 100644 index 0000000000..37850200c7 --- /dev/null +++ b/modules/benchmarks/e2e_test/selector_perf.es6 @@ -0,0 +1,41 @@ +var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util'); + +describe('ng2 selector benchmark', function () { + + var URL = 'benchmarks/web/compiler/selector_benchmark.html'; + + afterEach(perfUtil.verifyNoBrowserErrors); + + it('should log parse stats', function() { + perfUtil.runClickBenchmark({ + url: URL, + buttons: ['#parse'], + id: 'ng2.selector.parse', + params: [{ + name: 'selectors', value: 10000 + }] + }); + }); + + it('should log addSelectable stats', function() { + perfUtil.runClickBenchmark({ + buttons: ['#addSelectable'], + id: 'ng2.selector.addSelectable', + params: [{ + name: 'selectors', value: 10000 + }] + }); + }); + + it('should log match stats', function() { + perfUtil.runClickBenchmark({ + url: URL, + buttons: ['#match'], + id: 'ng2.selector.match', + params: [{ + name: 'selectors', value: 10000 + }] + }); + }); + +}); diff --git a/modules/benchmarks/e2e_test/selector_spec.es6 b/modules/benchmarks/e2e_test/selector_spec.es6 new file mode 100644 index 0000000000..b387c54364 --- /dev/null +++ b/modules/benchmarks/e2e_test/selector_spec.es6 @@ -0,0 +1,14 @@ +var testUtil = require('../../e2e_test_lib/e2e_test/test_util'); + +describe('ng2 selector benchmark', function () { + + var URL = 'benchmarks/web/compiler/selector_benchmark.html'; + + afterEach(testUtil.verifyNoBrowserErrors); + + it('should not throw errors', function() { + browser.get(URL); + testUtil.clickAll(['#parse', '#addSelectable', '#match']); + }); + +}); diff --git a/modules/benchmarks/e2e_test/tree_perf.es6 b/modules/benchmarks/e2e_test/tree_perf.es6 index 9fa485539c..0ca4ca260a 100644 --- a/modules/benchmarks/e2e_test/tree_perf.es6 +++ b/modules/benchmarks/e2e_test/tree_perf.es6 @@ -1,39 +1,31 @@ -"use strict"; -var benchpress = require('../../../tools/benchpress/index.js'); +var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util'); describe('ng2 tree benchmark', function () { var URL = 'benchmarks/web/tree/tree_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(perfUtil.verifyNoBrowserErrors); it('should log the ng stats', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#ng2DestroyDom', '#ng2CreateDom'], - logId: 'ng2.tree' + id: 'ng2.tree', + params: [{ + name: 'depth', value: 9 + }] }); }); it('should log the baseline stats', function() { - browser.get(URL); - runClickBenchmark({ + perfUtil.runClickBenchmark({ + url: URL, buttons: ['#baselineDestroyDom', '#baselineCreateDom'], - logId: 'baseline.tree' + id: 'baseline.tree', + params: [{ + name: 'depth', value: 9 + }] }); }); }); - -function runClickBenchmark(config) { - var buttons = config.buttons.map(function(selector) { - return $(selector); - }); - var params = Object.create(browser.params.benchmark); - params.logId = browser.params.lang+'.'+config.logId; - benchpress.runBenchmark(params, function() { - buttons.forEach(function(button) { - button.click(); - }); - }); -} diff --git a/modules/benchmarks/e2e_test/tree_spec.es6 b/modules/benchmarks/e2e_test/tree_spec.es6 index 4524d72791..de1829321e 100644 --- a/modules/benchmarks/e2e_test/tree_spec.es6 +++ b/modules/benchmarks/e2e_test/tree_spec.es6 @@ -1,20 +1,14 @@ -var benchpress = require('../../../tools/benchpress/index.js'); +var testUtil = require('../../e2e_test_lib/e2e_test/test_util'); describe('ng2 tree benchmark', function () { var URL = 'benchmarks/web/tree/tree_benchmark.html'; - afterEach(benchpress.verifyNoBrowserErrors); + afterEach(testUtil.verifyNoBrowserErrors); it('should not throw errors', function() { browser.get(URL); - clickAll(['#ng2CreateDom', '#ng2DestroyDom', '#baselineCreateDom', '#baselineDestroyDom']); + testUtil.clickAll(['#ng2CreateDom', '#ng2DestroyDom', '#baselineCreateDom', '#baselineDestroyDom']); }); }); - -function clickAll(buttonSelectors) { - buttonSelectors.forEach(function(selector) { - $(selector).click(); - }); -} diff --git a/modules/benchmarks/pubspec.yaml b/modules/benchmarks/pubspec.yaml index 9170c1101a..28052720c1 100644 --- a/modules/benchmarks/pubspec.yaml +++ b/modules/benchmarks/pubspec.yaml @@ -12,6 +12,8 @@ dependencies: path: ../core change_detection: path: ../change_detection + e2e_test_lib: + path: ../e2e_test_lib browser: '>=0.10.0 <0.11.0' transformers: - $dart2js: diff --git a/modules/benchmarks/src/change_detection/change_detection_benchmark.html b/modules/benchmarks/src/change_detection/change_detection_benchmark.html index 8f1707ae77..bd32a4c860 100644 --- a/modules/benchmarks/src/change_detection/change_detection_benchmark.html +++ b/modules/benchmarks/src/change_detection/change_detection_benchmark.html @@ -2,8 +2,19 @@ +

Params

+
+ Iterations: + +
+ +
+ +

Actions

+

- + +

$SCRIPTS$ diff --git a/modules/benchmarks/src/change_detection/change_detection_benchmark.js b/modules/benchmarks/src/change_detection/change_detection_benchmark.js index c58e51ca16..6b3be5a906 100644 --- a/modules/benchmarks/src/change_detection/change_detection_benchmark.js +++ b/modules/benchmarks/src/change_detection/change_detection_benchmark.js @@ -1,7 +1,7 @@ import {ListWrapper, MapWrapper} from 'facade/collection'; import {reflector} from 'reflection/reflection'; import {isPresent} from 'facade/lang'; -import {document, DOM} from 'facade/dom'; +import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util'; import { Lexer, @@ -12,8 +12,6 @@ import { } from 'change_detection/change_detection'; -var ITERATIONS = 500000; - class Obj { field0; field1; @@ -77,7 +75,7 @@ function setUpReflector() { }); } -function setUpBaseline() { +function setUpBaseline(iterations) { function createRow(i) { var obj = new Obj(); var index = i % 10; @@ -92,7 +90,7 @@ function setUpBaseline() { var head = createRow(0); var current = head; - for (var i = 1; i < ITERATIONS; i++) { + for (var i = 1; i < iterations; i++) { var newRow = createRow(i); current.next = newRow; current = newRow; @@ -100,7 +98,7 @@ function setUpBaseline() { return head; } -function setUpChangeDetection() { +function setUpChangeDetection(iterations) { var dispatcher = new DummyDispatcher(); var parser = new Parser(new Lexer()); @@ -139,7 +137,7 @@ function setUpChangeDetection() { proto(9) ]; - for (var i = 0; i < ITERATIONS; ++i) { + for (var i = 0; i < iterations; ++i) { var obj = new Obj(); var index = i % 10; obj.setField(index, i); @@ -154,11 +152,13 @@ function setUpChangeDetection() { } export function main () { - setUpReflector(); - var baselineHead = setUpBaseline(); - var ng2ChangeDetector = setUpChangeDetection(); + var iterations = getIntParameter('iterations'); - function baselineDetectChanges(_) { + setUpReflector(); + var baselineHead = setUpBaseline(iterations); + var ng2ChangeDetector = setUpChangeDetection(iterations); + + function baselineDetectChanges() { var current = baselineHead; while (isPresent(current)) { if (current.getter(current.obj) !== current.previousValue) { @@ -168,12 +168,12 @@ export function main () { } } - function ng2DetectChanges(_) { + function ng2DetectChanges() { ng2ChangeDetector.detectChanges(); } - DOM.on(DOM.querySelector(document, '#ng2DetectChanges'), 'click', ng2DetectChanges); - DOM.on(DOM.querySelector(document, '#baselineDetectChanges'), 'click', baselineDetectChanges); + bindAction('#ng2DetectChanges', ng2DetectChanges); + bindAction('#baselineDetectChanges', baselineDetectChanges); } diff --git a/modules/benchmarks/src/compiler/compiler_benchmark.html b/modules/benchmarks/src/compiler/compiler_benchmark.html index 460bb9bf54..30929d4478 100644 --- a/modules/benchmarks/src/compiler/compiler_benchmark.html +++ b/modules/benchmarks/src/compiler/compiler_benchmark.html @@ -2,8 +2,19 @@ - - +

Params

+
+ Elements: + +
+ +
+ +

Actions

+

+ + +