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.
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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']);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -2,8 +2,19 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Iterations:
|
||||
<input type="number" name="iterations" placeholder="iterations" value="500000">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="ng2DetectChanges">Ng2 detect changes</button>
|
||||
<button id="baselineDetectChanges">baseline detect changes</button>
|
||||
<button id="baselineDetectChanges">baselineDetectChanges</button>
|
||||
</p>
|
||||
|
||||
$SCRIPTS$
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,19 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<button id="compileWithBindings">Compile template with bindings</button>
|
||||
<button id="compileNoBindings">Compile template without bindings</button>
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Elements:
|
||||
<input type="number" name="elements" placeholder="elements" value="150">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="compileWithBindings">CompileWithBindings</button>
|
||||
<button id="compileNoBindings">CompileNoBindings</button>
|
||||
</p>
|
||||
|
||||
<template id="templateNoBindings">
|
||||
<div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4">
|
||||
|
||||
@@ -13,8 +13,7 @@ import {Decorator} from 'core/annotations/annotations';
|
||||
import {TemplateConfig} from 'core/annotations/template_config';
|
||||
|
||||
import {reflector} from 'reflection/reflection';
|
||||
|
||||
var COUNT = 30;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
function setupReflector() {
|
||||
reflector.registerType(BenchmarkComponent, {
|
||||
@@ -75,31 +74,33 @@ function setupReflector() {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
var count = getIntParameter('elements');
|
||||
|
||||
setupReflector();
|
||||
var reader = new DirectiveMetadataReader();
|
||||
var cache = new CompilerCache();
|
||||
var compiler = new Compiler(null, reader, new Parser(new Lexer()), cache);
|
||||
var annotatedComponent = reader.read(BenchmarkComponent);
|
||||
|
||||
var templateNoBindings = loadTemplate('templateNoBindings', COUNT);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', COUNT);
|
||||
var templateNoBindings = loadTemplate('templateNoBindings', count);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', count);
|
||||
|
||||
function compileNoBindings(_) {
|
||||
function compileNoBindings() {
|
||||
// Need to clone every time as the compiler might modify the template!
|
||||
var cloned = DOM.clone(templateNoBindings);
|
||||
cache.clear();
|
||||
compiler.compileAllLoaded(null, annotatedComponent, cloned);
|
||||
}
|
||||
|
||||
function compileWithBindings(_) {
|
||||
function compileWithBindings() {
|
||||
// Need to clone every time as the compiler might modify the template!
|
||||
var cloned = DOM.clone(templateWithBindings);
|
||||
cache.clear();
|
||||
compiler.compileAllLoaded(null, annotatedComponent, cloned);
|
||||
}
|
||||
|
||||
DOM.on(DOM.querySelector(document, '#compileNoBindings'), 'click', compileNoBindings);
|
||||
DOM.on(DOM.querySelector(document, '#compileWithBindings'), 'click', compileWithBindings);
|
||||
bindAction('#compileNoBindings', compileNoBindings);
|
||||
bindAction('#compileWithBindings', compileWithBindings);
|
||||
}
|
||||
|
||||
function loadTemplate(templateId, repeatCount) {
|
||||
|
||||
@@ -2,9 +2,20 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Selectors:
|
||||
<input type="number" name="selectors" placeholder="selectors" value="10000">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="parse">Selector.parse</button>
|
||||
<button id="addSelectable">Selector.addSelectable</button>
|
||||
<button id="match">Selector.match</button>
|
||||
</p>
|
||||
|
||||
$SCRIPTS$
|
||||
|
||||
|
||||
@@ -1,46 +1,45 @@
|
||||
import {document, DOM} from 'facade/dom';
|
||||
|
||||
import {SelectorMatcher} from "core/compiler/selector";
|
||||
import {CssSelector} from "core/compiler/selector";
|
||||
import {StringWrapper, Math} from 'facade/lang';
|
||||
import {ListWrapper} from 'facade/collection';
|
||||
|
||||
var COUNT = 1000;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
export function main() {
|
||||
var count = getIntParameter('selectors');
|
||||
|
||||
var fixedMatcher;
|
||||
var fixedSelectorStrings = [];
|
||||
var fixedSelectors = [];
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
ListWrapper.push(fixedSelectorStrings, randomSelector());
|
||||
}
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
ListWrapper.push(fixedSelectors, CssSelector.parse(fixedSelectorStrings[i]));
|
||||
}
|
||||
fixedMatcher = new SelectorMatcher();
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
fixedMatcher.addSelectable(fixedSelectors[i], i);
|
||||
}
|
||||
|
||||
function parse(_) {
|
||||
function parse() {
|
||||
var result = [];
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
ListWrapper.push(result, CssSelector.parse(fixedSelectorStrings[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function addSelectable(_) {
|
||||
function addSelectable() {
|
||||
var matcher = new SelectorMatcher();
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
matcher.addSelectable(fixedSelectors[i], i);
|
||||
}
|
||||
return matcher;
|
||||
}
|
||||
|
||||
function match(_) {
|
||||
function match() {
|
||||
var matchCount = 0;
|
||||
for (var i=0; i<COUNT; i++) {
|
||||
for (var i=0; i<count; i++) {
|
||||
fixedMatcher.match(fixedSelectors[i], (selected) => {
|
||||
matchCount += selected;
|
||||
});
|
||||
@@ -48,9 +47,9 @@ export function main() {
|
||||
return matchCount;
|
||||
}
|
||||
|
||||
DOM.on(DOM.querySelector(document, '#parse'), 'click', parse);
|
||||
DOM.on(DOM.querySelector(document, '#addSelectable'), 'click', addSelectable);
|
||||
DOM.on(DOM.querySelector(document, '#match'), 'click', match);
|
||||
bindAction('#parse', parse);
|
||||
bindAction('#addSelectable', addSelectable);
|
||||
bindAction('#match', match);
|
||||
}
|
||||
|
||||
function randomSelector() {
|
||||
|
||||
@@ -2,10 +2,21 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<button id="getByToken">Injector.get (token)</button>
|
||||
<button id="getByKey">Injector.get (key)</button>
|
||||
<button id="getChild">Injector.get (grand x 5 child)</button>
|
||||
<button id="instantiate">Injector.instantiate</button>
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Iterations:
|
||||
<input type="number" name="iterations" placeholder="iterations" value="20000">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="getByToken">getByToken</button>
|
||||
<button id="getByKey">getByKey</button>
|
||||
<button id="getChild">getChild</button>
|
||||
<button id="instantiate">instantiate</button>
|
||||
</div>
|
||||
|
||||
$SCRIPTS$
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Injector, Key} from "di/di";
|
||||
import {reflector} from 'reflection/reflection';
|
||||
import {document, DOM} from 'facade/dom';
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
var count = 0;
|
||||
|
||||
@@ -33,6 +33,8 @@ function setupReflector() {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
var iterations = getIntParameter('iterations');
|
||||
|
||||
setupReflector();
|
||||
var bindings = [A, B, C, D, E];
|
||||
var injector = new Injector(bindings);
|
||||
@@ -46,37 +48,37 @@ export function main() {
|
||||
createChild([]).
|
||||
createChild([]);
|
||||
|
||||
function getByToken (_) {
|
||||
for (var i = 0; i < 20000; ++i) {
|
||||
function getByToken () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
injector.get(D);
|
||||
injector.get(E);
|
||||
}
|
||||
}
|
||||
function getByKey(_) {
|
||||
for (var i = 0; i < 20000; ++i) {
|
||||
function getByKey() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
injector.get(D_KEY);
|
||||
injector.get(E_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
function getChild (_) {
|
||||
for (var i = 0; i < 20000; ++i) {
|
||||
function getChild () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
childInjector.get(D);
|
||||
childInjector.get(E);
|
||||
}
|
||||
}
|
||||
|
||||
function instantiate (_) {
|
||||
for (var i = 0; i < 5000; ++i) {
|
||||
function instantiate () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
var child = injector.createChild([E]);
|
||||
child.get(E);
|
||||
}
|
||||
}
|
||||
|
||||
DOM.on(DOM.querySelector(document, '#getByToken'), 'click', getByToken);
|
||||
DOM.on(DOM.querySelector(document, '#getByKey'), 'click', getByKey);
|
||||
DOM.on(DOM.querySelector(document, '#getChild'), 'click', getChild);
|
||||
DOM.on(DOM.querySelector(document, '#instantiate'), 'click', instantiate);
|
||||
bindAction('#getByToken', getByToken);
|
||||
bindAction('#getByKey', getByKey);
|
||||
bindAction('#getChild', getChild);
|
||||
bindAction('#instantiate', instantiate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,19 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<button id="instantiate">ElementInjector.instantiate</button>
|
||||
<button id="instantiateDirectives">ElementInjector.instantiateDirectives</button>
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Iterations:
|
||||
<input type="number" name="iterations" placeholder="iterations" value="20000">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="instantiate">instantiate</button>
|
||||
<button id="instantiateDirectives">instantiateDirectives</button>
|
||||
</p>
|
||||
|
||||
$SCRIPTS$
|
||||
</body>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import {reflector} from 'reflection/reflection';
|
||||
import {Injector} from 'di/di';
|
||||
import {ProtoElementInjector} from 'core/compiler/element_injector';
|
||||
import {document, DOM} from 'facade/dom';
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
var count = 0;
|
||||
var ITERATIONS = 20000;
|
||||
|
||||
function setupReflector() {
|
||||
reflector.registerType(A, {
|
||||
@@ -25,6 +24,8 @@ function setupReflector() {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
var iterations = getIntParameter('iterations');
|
||||
|
||||
setupReflector();
|
||||
var appInjector = new Injector([]);
|
||||
|
||||
@@ -32,22 +33,22 @@ export function main() {
|
||||
var proto = new ProtoElementInjector(null, 0, bindings);
|
||||
var elementInjector = proto.instantiate(null,null);
|
||||
|
||||
function instantiate (_) {
|
||||
for (var i = 0; i < ITERATIONS; ++i) {
|
||||
function instantiate () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
var ei = proto.instantiate(null, null);
|
||||
ei.instantiateDirectives(appInjector, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
function instantiateDirectives (_) {
|
||||
for (var i = 0; i < ITERATIONS; ++i) {
|
||||
function instantiateDirectives () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
elementInjector.clearDirectives();
|
||||
elementInjector.instantiateDirectives(appInjector, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
DOM.on(DOM.querySelector(document, '#instantiate'), 'click', instantiate);
|
||||
DOM.on(DOM.querySelector(document, '#instantiateDirectives'), 'click', instantiateDirectives);
|
||||
bindAction('#instantiate', instantiate);
|
||||
bindAction('#instantiateDirectives', instantiateDirectives);
|
||||
}
|
||||
|
||||
class A {
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Depth:
|
||||
<input type="number" name="depth" placeholder="depth" value="9">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Angular2 tree benchmark</h2>
|
||||
<p>
|
||||
<button id="ng2DestroyDom">destroyDom</button>
|
||||
|
||||
@@ -10,8 +10,7 @@ import {LifeCycle} from 'core/life_cycle/life_cycle';
|
||||
import {reflector} from 'reflection/reflection';
|
||||
import {DOM, document, window, Element, gc} from 'facade/dom';
|
||||
import {isPresent} from 'facade/lang';
|
||||
|
||||
var MAX_DEPTH = 9;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
function setupReflector() {
|
||||
// TODO: Put the general calls to reflector.register... in a shared file
|
||||
@@ -121,14 +120,16 @@ function setupReflector() {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
setupReflector();
|
||||
var maxDepth = getIntParameter('depth');
|
||||
|
||||
setupReflector();
|
||||
|
||||
var app;
|
||||
var changeDetector;
|
||||
var baselineRootTreeComponent;
|
||||
var count = 0;
|
||||
|
||||
function ng2DestroyDom(_) {
|
||||
function ng2DestroyDom() {
|
||||
// TODO: We need an initial value as otherwise the getter for data.value will fail
|
||||
// --> this should be already caught in change detection!
|
||||
app.initData = new TreeNode('', null, null);
|
||||
@@ -136,16 +137,16 @@ export function main() {
|
||||
}
|
||||
|
||||
function profile(create, destroy, name) {
|
||||
return function(_) {
|
||||
return function() {
|
||||
window.console.profile(name + ' w GC');
|
||||
var duration = 0;
|
||||
var count = 0;
|
||||
while(count++ < 150) {
|
||||
gc();
|
||||
var start = window.performance.now();
|
||||
create(_);
|
||||
create();
|
||||
duration += window.performance.now() - start;
|
||||
destroy(_);
|
||||
destroy();
|
||||
}
|
||||
window.console.profileEnd(name + ' w GC');
|
||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||
@@ -155,21 +156,21 @@ export function main() {
|
||||
count = 0;
|
||||
while(count++ < 150) {
|
||||
var start = window.performance.now();
|
||||
create(_);
|
||||
create();
|
||||
duration += window.performance.now() - start;
|
||||
destroy(_);
|
||||
destroy();
|
||||
}
|
||||
window.console.profileEnd(name + ' w/o GC');
|
||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||
};
|
||||
}
|
||||
|
||||
function ng2CreateDom(_) {
|
||||
function ng2CreateDom() {
|
||||
var values = count++ % 2 == 0 ?
|
||||
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
|
||||
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
|
||||
|
||||
app.initData = buildTree(MAX_DEPTH, values, 0);
|
||||
app.initData = buildTree(maxDepth, values, 0);
|
||||
changeDetector.detectChanges();
|
||||
}
|
||||
|
||||
@@ -179,33 +180,35 @@ export function main() {
|
||||
bootstrap(AppComponent).then((injector) => {
|
||||
changeDetector = injector.get(ChangeDetector);
|
||||
app = injector.get(AppComponent);
|
||||
DOM.on(DOM.querySelector(document, '#ng2DestroyDom'), 'click', ng2DestroyDom);
|
||||
DOM.on(DOM.querySelector(document, '#ng2CreateDom'), 'click', ng2CreateDom);
|
||||
DOM.on(DOM.querySelector(document, '#ng2UpdateDomProfile'), 'click', profile(ng2CreateDom, noop, 'ng2-update'));
|
||||
DOM.on(DOM.querySelector(document, '#ng2CreateDomProfile'), 'click', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create'));
|
||||
bindAction('#ng2DestroyDom', ng2DestroyDom);
|
||||
bindAction('#ng2CreateDom', ng2CreateDom);
|
||||
bindAction('#ng2UpdateDomProfile', profile(ng2CreateDom, noop, 'ng2-update'));
|
||||
bindAction('#ng2CreateDomProfile', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create'));
|
||||
});
|
||||
}
|
||||
|
||||
function baselineDestroyDom(_) {
|
||||
function baselineDestroyDom() {
|
||||
baselineRootTreeComponent.update(new TreeNode('', null, null));
|
||||
}
|
||||
|
||||
function baselineCreateDom(_) {
|
||||
function baselineCreateDom() {
|
||||
var values = count++ % 2 == 0 ?
|
||||
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
|
||||
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
|
||||
|
||||
baselineRootTreeComponent.update(buildTree(MAX_DEPTH, values, 0));
|
||||
baselineRootTreeComponent.update(buildTree(maxDepth, values, 0));
|
||||
}
|
||||
|
||||
function initBaseline() {
|
||||
var tree = DOM.createElement('tree');
|
||||
DOM.appendChild(DOM.querySelector(document, 'baseline'), tree);
|
||||
baselineRootTreeComponent = new BaseLineTreeComponent(tree);
|
||||
DOM.on(DOM.querySelector(document, '#baselineDestroyDom'), 'click', baselineDestroyDom);
|
||||
DOM.on(DOM.querySelector(document, '#baselineCreateDom'), 'click', baselineCreateDom);
|
||||
DOM.on(DOM.querySelector(document, '#baselineUpdateDomProfile'), 'click', profile(baselineCreateDom, noop, 'baseline-update'));
|
||||
DOM.on(DOM.querySelector(document, '#baselineCreateDomProfile'), 'click', profile(baselineCreateDom, baselineDestroyDom, 'baseline-create'));
|
||||
|
||||
bindAction('#baselineDestroyDom', baselineDestroyDom);
|
||||
bindAction('#baselineCreateDom', baselineCreateDom);
|
||||
|
||||
bindAction('#baselineUpdateDomProfile', profile(baselineCreateDom, noop, 'baseline-update'));
|
||||
bindAction('#baselineCreateDomProfile', profile(baselineCreateDom, baselineDestroyDom, 'baseline-create'));
|
||||
}
|
||||
|
||||
initNg2();
|
||||
|
||||
@@ -1,39 +1,31 @@
|
||||
"use strict";
|
||||
var benchpress = require('../../../tools/benchpress/index.js');
|
||||
var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util');
|
||||
|
||||
describe('ng1.x compiler benchmark', function () {
|
||||
|
||||
var URL = 'benchmarks_external/web/compiler/compiler_benchmark.html';
|
||||
|
||||
afterEach(benchpress.verifyNoBrowserErrors);
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
|
||||
it('should log withBinding stats', function() {
|
||||
browser.get(URL);
|
||||
runClickBenchmark({
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#compileWithBindings'],
|
||||
logId: 'ng1.compile.withBindings'
|
||||
id: 'ng1.compile.withBindings',
|
||||
params: [{
|
||||
name: 'elementCount', value: 150
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
it('should log noBindings stats', function() {
|
||||
browser.get(URL);
|
||||
runClickBenchmark({
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#compileNoBindings'],
|
||||
logId: 'ng1.compile.noBindings'
|
||||
id: 'ng1.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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
var benchpress = require('../../../tools/benchpress/index.js');
|
||||
var testUtil = require('../../e2e_test_lib/e2e_test/test_util');
|
||||
|
||||
describe('ng1.x compiler benchmark', function () {
|
||||
|
||||
var URL = 'benchmarks_external/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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,31 +1,20 @@
|
||||
"use strict";
|
||||
var benchpress = require('../../../tools/benchpress/index.js');
|
||||
var perfUtil = require('../../e2e_test_lib/e2e_test/perf_util');
|
||||
|
||||
describe('ng1.x tree benchmark', function () {
|
||||
|
||||
var URL = 'benchmarks_external/web/tree/tree_benchmark.html';
|
||||
|
||||
afterEach(benchpress.verifyNoBrowserErrors);
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
|
||||
it('should log the stats', function() {
|
||||
browser.get(URL);
|
||||
runClickBenchmark({
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#destroyDom', '#createDom'],
|
||||
logId: 'ng1.tree'
|
||||
id: 'ng1.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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
var benchpress = require('../../../tools/benchpress/index.js');
|
||||
var testUtil = require('../../e2e_test_lib/e2e_test/test_util');
|
||||
|
||||
describe('ng1.x tree benchmark', function () {
|
||||
|
||||
var URL = 'benchmarks_external/web/tree/tree_benchmark.html';
|
||||
|
||||
afterEach(benchpress.verifyNoBrowserErrors);
|
||||
afterEach(testUtil.verifyNoBrowserErrors);
|
||||
|
||||
it('should not throw errors', function() {
|
||||
browser.get(URL);
|
||||
clickAll(['#createDom', '#destroyDom']);
|
||||
testUtil.clickAll(['#createDom', '#destroyDom']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function clickAll(buttonSelectors) {
|
||||
buttonSelectors.forEach(function(selector) {
|
||||
$(selector).click();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ name: benchmarks_external
|
||||
environment:
|
||||
sdk: '>=1.4.0'
|
||||
dependencies:
|
||||
e2e_test_lib:
|
||||
path: ../e2e_test_lib
|
||||
angular: ">=1.0.0 <2.0.0"
|
||||
browser: '>=0.10.0 <0.11.0'
|
||||
transformers:
|
||||
|
||||
@@ -4,11 +4,12 @@ library compiler_benchmark_ng10;
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:angular/application_factory.dart';
|
||||
import 'dart:html';
|
||||
|
||||
var COUNT = 30;
|
||||
import 'package:e2e_test_lib/benchmark_util.dart';
|
||||
|
||||
main() {
|
||||
|
||||
var count = getIntParameter('elements');
|
||||
|
||||
var m = new Module()
|
||||
..bind(Dir0)
|
||||
..bind(Dir1)
|
||||
@@ -16,25 +17,25 @@ main() {
|
||||
..bind(Dir3)
|
||||
..bind(Dir4);
|
||||
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', COUNT);
|
||||
var templateNoBindings = loadTemplate('templateWithBindings', COUNT);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', count);
|
||||
var templateNoBindings = loadTemplate('templateWithBindings', count);
|
||||
|
||||
final injector = applicationFactory().addModule(m).run();
|
||||
final compiler = injector.get(Compiler);
|
||||
final directiveMap = injector.get(DirectiveMap);
|
||||
|
||||
compileWithBindings(_) {
|
||||
compileWithBindings() {
|
||||
final cloned = templateWithBindings.clone(true);
|
||||
compiler([cloned], directiveMap);
|
||||
}
|
||||
|
||||
compileNoBindings(_) {
|
||||
compileNoBindings() {
|
||||
final cloned = templateNoBindings.clone(true);
|
||||
compiler([cloned], directiveMap);
|
||||
}
|
||||
|
||||
document.querySelector('#compileWithBindings').addEventListener('click', compileWithBindings);
|
||||
document.querySelector('#compileNoBindings').addEventListener('click', compileNoBindings);
|
||||
bindAction('#compileWithBindings', compileWithBindings);
|
||||
bindAction('#compileNoBindings', compileNoBindings);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// compiler benchmark in AngularJS 1.x
|
||||
var COUNT = 30;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
export function main() {
|
||||
var ngEl = document.createElement('div');
|
||||
@@ -74,19 +74,20 @@ angular.module('app', [])
|
||||
};
|
||||
}])
|
||||
.run(['$compile', function($compile) {
|
||||
var templateNoBindings = loadTemplate('templateNoBindings', COUNT);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', COUNT);
|
||||
var count = getIntParameter('elements');
|
||||
var templateNoBindings = loadTemplate('templateNoBindings', count);
|
||||
var templateWithBindings = loadTemplate('templateWithBindings', count);
|
||||
|
||||
document.querySelector('#compileWithBindings').addEventListener('click', compileWithBindings, false);
|
||||
document.querySelector('#compileNoBindings').addEventListener('click', compileNoBindings, false);
|
||||
bindAction('#compileWithBindings', compileWithBindings);
|
||||
bindAction('#compileNoBindings', compileNoBindings);
|
||||
|
||||
function compileNoBindings(_) {
|
||||
function compileNoBindings() {
|
||||
// Need to clone every time as the compiler might modify the template!
|
||||
var cloned = templateNoBindings.cloneNode(true);
|
||||
$compile(cloned);
|
||||
}
|
||||
|
||||
function compileWithBindings(_) {
|
||||
function compileWithBindings() {
|
||||
// Need to clone every time as the compiler might modify the template!
|
||||
var cloned = templateWithBindings.cloneNode(true);
|
||||
$compile(cloned);
|
||||
|
||||
@@ -2,8 +2,19 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<button id="compileWithBindings">Compile template with bindings</button>
|
||||
<button id="compileNoBindings">Compile template without bindings</button>
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Elements:
|
||||
<input type="number" name="elements" placeholder="elements" value="150">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="compileWithBindings">CompileWithBindings</button>
|
||||
<button id="compileNoBindings">CompileNoBindings</button>
|
||||
</p>
|
||||
|
||||
<template id="templateNoBindings">
|
||||
<div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4">
|
||||
|
||||
@@ -4,8 +4,7 @@ library tree_benchmark_ng10;
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:angular/application_factory.dart';
|
||||
import 'dart:html';
|
||||
|
||||
var MAX_DEPTH = 9;
|
||||
import 'package:e2e_test_lib/benchmark_util.dart';
|
||||
|
||||
setup() {
|
||||
|
||||
@@ -20,29 +19,31 @@ setup() {
|
||||
}
|
||||
|
||||
main() {
|
||||
var maxDepth = getIntParameter('depth');
|
||||
|
||||
final injector = setup();
|
||||
final zone = injector.get(VmTurnZone);
|
||||
final rootScope = injector.get(Scope);
|
||||
var count = 0;
|
||||
|
||||
destroyDom(_) {
|
||||
destroyDom() {
|
||||
zone.run(() {
|
||||
rootScope.context['initData'] = new TreeNode('');
|
||||
});
|
||||
}
|
||||
|
||||
createDom(_) {
|
||||
createDom() {
|
||||
zone.run(() {
|
||||
var values = count++ % 2 == 0 ?
|
||||
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
|
||||
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
|
||||
|
||||
rootScope.context['initData'] = buildTree(MAX_DEPTH, values, 0);
|
||||
rootScope.context['initData'] = buildTree(maxDepth, values, 0);
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelector('#destroyDom').addEventListener('click', destroyDom);
|
||||
document.querySelector('#createDom').addEventListener('click', createDom);
|
||||
bindAction('#destroyDom', destroyDom);
|
||||
bindAction('#createDom', createDom);
|
||||
}
|
||||
|
||||
@Component(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// tree benchmark in AngularJS 1.x
|
||||
var MAX_DEPTH = 9;
|
||||
import {getIntParameter, bindAction} from 'e2e_test_lib/benchmark_util';
|
||||
|
||||
export function main() {
|
||||
angular.bootstrap(document.body, ['app']);
|
||||
@@ -57,24 +57,24 @@ angular.module('app', [])
|
||||
}])
|
||||
.run(['$rootScope', function($rootScope) {
|
||||
var count = 0;
|
||||
var maxDepth = getIntParameter('depth');
|
||||
|
||||
document.querySelector('#destroyDom').addEventListener('click', destroyDom, false);
|
||||
document.querySelector('#createDom').addEventListener('click', createDom, false);
|
||||
bindAction('#destroyDom', destroyDom);
|
||||
bindAction('#createDom', createDom);
|
||||
|
||||
function destroyDom(_) {
|
||||
function destroyDom() {
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.initData = new TreeNode('', null, null);
|
||||
});
|
||||
}
|
||||
|
||||
function createDom(_) {
|
||||
var maxDepth = MAX_DEPTH;
|
||||
function createDom() {
|
||||
var values = count++ % 2 == 0 ?
|
||||
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
|
||||
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
|
||||
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.initData = buildTree(MAX_DEPTH, values, 0);
|
||||
$rootScope.initData = buildTree(maxDepth, values, 0);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Depth:
|
||||
<input type="number" name="depth" placeholder="depth" value="9">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>AngularJS/Dart 1.x tree benchmark</h2>
|
||||
<p>
|
||||
<button id="destroyDom">destroyDom</button>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
var benchpress = require('../../../tools/benchpress/index.js');
|
||||
var webdriver = require('protractor/node_modules/selenium-webdriver');
|
||||
|
||||
module.exports = {
|
||||
runClickBenchmark: runClickBenchmark,
|
||||
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors
|
||||
};
|
||||
|
||||
function runClickBenchmark(config) {
|
||||
var url = encodeURI(config.url + '?' + config.params.map(function(param) {
|
||||
return param.name + '=' + param.value;
|
||||
}).join('&'));
|
||||
browser.get(url);
|
||||
var buttons = config.buttons.map(function(selector) {
|
||||
return $(selector);
|
||||
});
|
||||
var benchmarkConfig = Object.create(browser.params.benchmark);
|
||||
benchmarkConfig.id = browser.params.lang+'.'+config.id;
|
||||
benchmarkConfig.params = config.params;
|
||||
benchpress.runBenchmark(benchmarkConfig, function() {
|
||||
buttons.forEach(function(button) {
|
||||
button.click();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
var benchpress = require('../../../tools/benchpress/index.js');
|
||||
|
||||
module.exports = {
|
||||
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors,
|
||||
clickAll: clickAll
|
||||
};
|
||||
|
||||
function clickAll(buttonSelectors) {
|
||||
buttonSelectors.forEach(function(selector) {
|
||||
$(selector).click();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
name: e2e_test_lib
|
||||
environment:
|
||||
sdk: '>=1.4.0'
|
||||
dependencies:
|
||||
facade:
|
||||
path: ../facade
|
||||
browser: '>=0.10.0 <0.11.0'
|
||||
@@ -0,0 +1,17 @@
|
||||
import {DOM, document, location} from 'facade/dom';
|
||||
import {NumberWrapper, BaseException, isBlank} from 'facade/lang';
|
||||
|
||||
export function getIntParameter(name:string) {
|
||||
var el = DOM.querySelector(document, `input[name="${name}"]`);
|
||||
if (isBlank(el)) {
|
||||
throw new BaseException(`Could not find and input field with name ${name}`);
|
||||
}
|
||||
return NumberWrapper.parseInt(el.value, 10);
|
||||
}
|
||||
|
||||
export function bindAction(selector:string, callback:Function) {
|
||||
var el = DOM.querySelector(document, selector);
|
||||
DOM.on(el, 'click', function(_) {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user