refactor (angular2/test_lib): ts'ifying last of test_lib
Translates last .es6 files in angular2/src/test_lib to TypeScript.
This commit is contained in:
parent
2b60d1bae1
commit
0602f68ae3
|
@ -1,3 +1,3 @@
|
||||||
library angular2.perf_util;
|
library angular2.test_lib.perf_util;
|
||||||
|
|
||||||
// empty as this file is node.js specific and should not be transpiled to dart
|
// empty as this file is node.js specific and should not be transpiled to dart
|
|
@ -1,72 +0,0 @@
|
||||||
var testUtil = require('./e2e_util');
|
|
||||||
|
|
||||||
var benchpress = require('benchpress/benchpress');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
runClickBenchmark: runClickBenchmark,
|
|
||||||
runBenchmark: runBenchmark,
|
|
||||||
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
|
|
||||||
};
|
|
||||||
|
|
||||||
function runClickBenchmark(config) {
|
|
||||||
var buttons = config.buttons.map(function(selector) {
|
|
||||||
return $(selector);
|
|
||||||
});
|
|
||||||
config.work = function() {
|
|
||||||
buttons.forEach(function(button) {
|
|
||||||
button.click();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return runBenchmark(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
function runBenchmark(config) {
|
|
||||||
return getScaleFactor(browser.params.benchmark.scaling).then(function(scaleFactor) {
|
|
||||||
var description = {};
|
|
||||||
var urlParams = [];
|
|
||||||
if (config.params) {
|
|
||||||
config.params.forEach(function(param) {
|
|
||||||
var name = param.name;
|
|
||||||
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
|
||||||
urlParams.push(name + '=' + value);
|
|
||||||
description[name] = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
|
||||||
return browser.get(url).then(function() {
|
|
||||||
return benchpressRunner.sample({
|
|
||||||
id: config.id,
|
|
||||||
execute: config.work,
|
|
||||||
prepare: config.prepare,
|
|
||||||
microMetrics: config.microMetrics,
|
|
||||||
bindings: [
|
|
||||||
benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getScaleFactor(possibleScalings) {
|
|
||||||
return browser.executeScript('return navigator.userAgent').then(function(userAgent:string) {
|
|
||||||
var scaleFactor = 1;
|
|
||||||
possibleScalings.forEach(function(entry) {
|
|
||||||
if (userAgent.match(entry.userAgent)) {
|
|
||||||
scaleFactor = entry.value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return scaleFactor;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyScaleFactor(value, scaleFactor, method) {
|
|
||||||
if (method === 'log2') {
|
|
||||||
return value + Math.log(scaleFactor) / Math.LN2;
|
|
||||||
} else if (method === 'sqrt') {
|
|
||||||
return value * Math.sqrt(scaleFactor);
|
|
||||||
} else if (method === 'linear') {
|
|
||||||
return value * scaleFactor;
|
|
||||||
} else {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/// <reference path="../../typings/node/node.d.ts" />
|
||||||
|
/// <reference path="../../typings/angular-protractor/angular-protractor.d.ts" />
|
||||||
|
|
||||||
|
var testUtil = require('./e2e_util');
|
||||||
|
|
||||||
|
var benchpress = require('benchpress/benchpress');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
runClickBenchmark: runClickBenchmark,
|
||||||
|
runBenchmark: runBenchmark,
|
||||||
|
verifyNoBrowserErrors: testUtil.verifyNoBrowserErrors
|
||||||
|
};
|
||||||
|
|
||||||
|
function runClickBenchmark(config) {
|
||||||
|
var buttons = config.buttons.map(function(selector) { return $(selector); });
|
||||||
|
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
|
||||||
|
return runBenchmark(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runBenchmark(config) {
|
||||||
|
return getScaleFactor(browser.params.benchmark.scaling)
|
||||||
|
.then(function(scaleFactor) {
|
||||||
|
var description = {};
|
||||||
|
var urlParams = [];
|
||||||
|
if (config.params) {
|
||||||
|
config.params.forEach(function(param) {
|
||||||
|
var name = param.name;
|
||||||
|
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
||||||
|
urlParams.push(name + '=' + value);
|
||||||
|
description[name] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||||
|
return browser.get(url).then(function() {
|
||||||
|
return new benchpress.Runner().sample({
|
||||||
|
id: config.id,
|
||||||
|
execute: config.work,
|
||||||
|
prepare: config.prepare,
|
||||||
|
microMetrics: config.microMetrics,
|
||||||
|
bindings:
|
||||||
|
[benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue(description)]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getScaleFactor(possibleScalings) {
|
||||||
|
return browser.executeScript('return navigator.userAgent')
|
||||||
|
.then(function(userAgent: string) {
|
||||||
|
var scaleFactor = 1;
|
||||||
|
possibleScalings.forEach(function(entry) {
|
||||||
|
if (userAgent.match(entry.userAgent)) {
|
||||||
|
scaleFactor = entry.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return scaleFactor;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyScaleFactor(value, scaleFactor, method) {
|
||||||
|
if (method === 'log2') {
|
||||||
|
return value + Math.log(scaleFactor) / Math.LN2;
|
||||||
|
} else if (method === 'sqrt') {
|
||||||
|
return value * Math.sqrt(scaleFactor);
|
||||||
|
} else if (method === 'linear') {
|
||||||
|
return value * scaleFactor;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
library angular2.test_lib.shims_for_ie;
|
|
@ -1,13 +0,0 @@
|
||||||
//function.name
|
|
||||||
/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/
|
|
||||||
if (!(function f() {}).name) {
|
|
||||||
Object.defineProperty(Function.prototype, 'name', {
|
|
||||||
get: function() {
|
|
||||||
var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
|
|
||||||
// For better performance only parse once, and then cache the
|
|
||||||
// result through a new accessor for repeated access.
|
|
||||||
Object.defineProperty(this, 'name', { value: name });
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// function.name
|
||||||
|
/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/
|
||||||
|
if (!Object.hasOwnProperty('name')) {
|
||||||
|
Object.defineProperty(Function.prototype, 'name', {
|
||||||
|
get: function() {
|
||||||
|
var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
|
||||||
|
// For better performance only parse once, and then cache the
|
||||||
|
// result through a new accessor for repeated access.
|
||||||
|
Object.defineProperty(this, 'name', {value: name});
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,96 +1,87 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 change detection benchmark', function() {
|
describe('ng2 change detection benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/change_detection/change_detection_benchmark.html';
|
var URL = 'benchmarks/src/change_detection/change_detection_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log ng stats (dynamic, reads)', function(done) {
|
it('should log ng stats (dynamic, reads)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#ng2ChangeDetectionDynamicReads'],
|
buttons: ['#ng2ChangeDetectionDynamicReads'],
|
||||||
id: 'ng2.changeDetection.dynamic.reads',
|
id: 'ng2.changeDetection.dynamic.reads',
|
||||||
params: [
|
params: [
|
||||||
{name: 'numberOfChecks', value: 900000},
|
{name: 'numberOfChecks', value: 900000},
|
||||||
{name: 'iterations', value: 20, scale: 'linear'}
|
{name: 'iterations', value: 20, scale: 'linear'}
|
||||||
],
|
],
|
||||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log ng stats (dynamic, writes)', function(done) {
|
it('should log ng stats (dynamic, writes)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#ng2ChangeDetectionDynamicWrites'],
|
buttons: ['#ng2ChangeDetectionDynamicWrites'],
|
||||||
id: 'ng2.changeDetection.dynamic.writes',
|
id: 'ng2.changeDetection.dynamic.writes',
|
||||||
params: [
|
params: [
|
||||||
{name: 'numberOfChecks', value: 900000},
|
{name: 'numberOfChecks', value: 900000},
|
||||||
{name: 'iterations', value: 20, scale: 'linear'}
|
{name: 'iterations', value: 20, scale: 'linear'}
|
||||||
],
|
],
|
||||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log ng stats (jit, reads)', function(done) {
|
it('should log ng stats (jit, reads)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#ng2ChangeDetectionJitReads'],
|
buttons: ['#ng2ChangeDetectionJitReads'],
|
||||||
id: 'ng2.changeDetection.jit.reads',
|
id: 'ng2.changeDetection.jit.reads',
|
||||||
params: [
|
params: [
|
||||||
{name: 'numberOfChecks', value: 900000},
|
{name: 'numberOfChecks', value: 900000},
|
||||||
{name: 'iterations', value: 20, scale: 'linear'}
|
{name: 'iterations', value: 20, scale: 'linear'}
|
||||||
],
|
],
|
||||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log ng stats (jit, writes)', function(done) {
|
it('should log ng stats (jit, writes)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#ng2ChangeDetectionJitWrites'],
|
buttons: ['#ng2ChangeDetectionJitWrites'],
|
||||||
id: 'ng2.changeDetection.jit.writes',
|
id: 'ng2.changeDetection.jit.writes',
|
||||||
params: [
|
params: [
|
||||||
{name: 'numberOfChecks', value: 900000},
|
{name: 'numberOfChecks', value: 900000},
|
||||||
{name: 'iterations', value: 20, scale: 'linear'}
|
{name: 'iterations', value: 20, scale: 'linear'}
|
||||||
],
|
],
|
||||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log baseline stats (create)', function(done) {
|
it('should log baseline stats (create)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#baselineChangeDetectionReads'],
|
buttons: ['#baselineChangeDetectionReads'],
|
||||||
id: 'baseline.changeDetection.reads',
|
id: 'baseline.changeDetection.reads',
|
||||||
params: [
|
params: [
|
||||||
{name: 'numberOfChecks', value: 900000},
|
{name: 'numberOfChecks', value: 900000},
|
||||||
{name: 'iterations', value: 20, scale: 'linear'}
|
{name: 'iterations', value: 20, scale: 'linear'}
|
||||||
],
|
],
|
||||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log baseline stats (update)', function(done) {
|
it('should log baseline stats (update)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#baselineChangeDetectionWrites'],
|
buttons: ['#baselineChangeDetectionWrites'],
|
||||||
id: 'baseline.changeDetection.writes',
|
id: 'baseline.changeDetection.writes',
|
||||||
params: [
|
params: [
|
||||||
{name: 'numberOfChecks', value: 900000},
|
{name: 'numberOfChecks', value: 900000},
|
||||||
{name: 'iterations', value: 20, scale: 'linear'}
|
{name: 'iterations', value: 20, scale: 'linear'}
|
||||||
],
|
],
|
||||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
/// <reference path="../../angular2/typings/angular-protractor/angular-protractor.d.ts" />
|
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 compiler benchmark', function() {
|
describe('ng2 compiler benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/compiler/compiler_benchmark.html';
|
var URL = 'benchmarks/src/compiler/compiler_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log withBindings stats', function(done) {
|
it('should log withBindings stats', function(done) {
|
||||||
perfUtil.runBenchmark({
|
runBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
id: 'ng2.compile.withBindings',
|
id: 'ng2.compile.withBindings',
|
||||||
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
||||||
work: function() {
|
work: function() {
|
||||||
browser.executeScript('document.querySelector("#compileWithBindings").click()');
|
browser.executeScript('document.querySelector("#compileWithBindings").click()');
|
||||||
browser.sleep(500);
|
browser.sleep(500);
|
||||||
}
|
}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log noBindings stats', function(done) {
|
it('should log noBindings stats', function(done) {
|
||||||
perfUtil.runBenchmark({
|
runBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
id: 'ng2.compile.noBindings',
|
id: 'ng2.compile.noBindings',
|
||||||
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
||||||
work: function() {
|
work: function() {
|
||||||
browser.executeScript('document.querySelector("#compileNoBindings").click()');
|
browser.executeScript('document.querySelector("#compileNoBindings").click()');
|
||||||
browser.sleep(500);
|
browser.sleep(500);
|
||||||
}
|
}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 cost benchmark', function() {
|
describe('ng2 cost benchmark', function() {
|
||||||
|
|
||||||
|
@ -10,35 +7,32 @@ describe('ng2 cost benchmark', function() {
|
||||||
// Number of components to create in a single iteration
|
// Number of components to create in a single iteration
|
||||||
var benchmarkSize = 200;
|
var benchmarkSize = 200;
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log stats for baseline (plain components)', function(done) {
|
it('should log stats for baseline (plain components)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#reset', '#createPlainComponents'],
|
buttons: ['#reset', '#createPlainComponents'],
|
||||||
id: 'ng2.costs.baseline',
|
id: 'ng2.costs.baseline',
|
||||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log stats for components with decorators', function(done) {
|
it('should log stats for components with decorators', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#reset', '#createComponentsWithDirectives'],
|
buttons: ['#reset', '#createComponentsWithDirectives'],
|
||||||
id: 'ng2.costs.decorators',
|
id: 'ng2.costs.decorators',
|
||||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log stats for dynamic components', function(done) {
|
it('should log stats for dynamic components', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#reset', '#createDynamicComponents'],
|
buttons: ['#reset', '#createDynamicComponents'],
|
||||||
id: 'ng2.costs.dynamic',
|
id: 'ng2.costs.dynamic',
|
||||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,56 +1,49 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 di benchmark', function() {
|
describe('ng2 di benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/di/di_benchmark.html';
|
var URL = 'benchmarks/src/di/di_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log the stats for getByToken', function(done) {
|
it('should log the stats for getByToken', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#getByToken'],
|
buttons: ['#getByToken'],
|
||||||
id: 'ng2.di.getByToken',
|
id: 'ng2.di.getByToken',
|
||||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||||
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the stats for getByKey', function(done) {
|
it('should log the stats for getByKey', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#getByKey'],
|
buttons: ['#getByKey'],
|
||||||
id: 'ng2.di.getByKey',
|
id: 'ng2.di.getByKey',
|
||||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||||
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the stats for getChild', function(done) {
|
it('should log the stats for getChild', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#getChild'],
|
buttons: ['#getChild'],
|
||||||
id: 'ng2.di.getChild',
|
id: 'ng2.di.getChild',
|
||||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||||
microMetrics: {'injectAvg': 'avg time for getChild (in ms)'}
|
microMetrics: {'injectAvg': 'avg time for getChild (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the stats for instantiate', function(done) {
|
it('should log the stats for instantiate', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#instantiate'],
|
buttons: ['#instantiate'],
|
||||||
id: 'ng2.di.instantiate',
|
id: 'ng2.di.instantiate',
|
||||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||||
microMetrics: {'injectAvg': 'avg time for instantiate (in ms)'}
|
microMetrics: {'injectAvg': 'avg time for instantiate (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,28 +51,26 @@ describe('ng2 di benchmark', function() {
|
||||||
* of binding types: Type, unresolved, unflattened.
|
* of binding types: Type, unresolved, unflattened.
|
||||||
*/
|
*/
|
||||||
it('should log the stats for createVariety', function(done) {
|
it('should log the stats for createVariety', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#createVariety'],
|
buttons: ['#createVariety'],
|
||||||
id: 'ng2.di.createVariety',
|
id: 'ng2.di.createVariety',
|
||||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||||
microMetrics: {'injectAvg': 'avg time for createVariety (in ms)'}
|
microMetrics: {'injectAvg': 'avg time for createVariety (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as 'createVariety' benchmark but operates on fully resolved bindings.
|
* Same as 'createVariety' benchmark but operates on fully resolved bindings.
|
||||||
*/
|
*/
|
||||||
it('should log the stats for createVarietyResolved', function(done) {
|
it('should log the stats for createVarietyResolved', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#createVarietyResolved'],
|
buttons: ['#createVarietyResolved'],
|
||||||
id: 'ng2.di.createVarietyResolved',
|
id: 'ng2.di.createVarietyResolved',
|
||||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||||
microMetrics: {'injectAvg': 'avg time for createVarietyResolved (in ms)'}
|
microMetrics: {'injectAvg': 'avg time for createVarietyResolved (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,34 +1,29 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 element injector benchmark', function() {
|
describe('ng2 element injector benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/element_injector/element_injector_benchmark.html';
|
var URL = 'benchmarks/src/element_injector/element_injector_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log the stats for instantiate', function(done) {
|
it('should log the stats for instantiate', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#instantiate'],
|
buttons: ['#instantiate'],
|
||||||
id: 'ng2.elementInjector.instantiate',
|
id: 'ng2.elementInjector.instantiate',
|
||||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||||
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the stats for hydrate', function(done) {
|
it('should log the stats for hydrate', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#hydrate'],
|
buttons: ['#hydrate'],
|
||||||
id: 'ng2.elementInjector.hydrate',
|
id: 'ng2.elementInjector.hydrate',
|
||||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||||
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 largetable benchmark', function() {
|
describe('ng2 largetable benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/largetable/largetable_benchmark.html';
|
var URL = 'benchmarks/src/largetable/largetable_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
// Not yet implemented:
|
// Not yet implemented:
|
||||||
// 'ngBind',
|
// 'ngBind',
|
||||||
|
@ -19,33 +16,31 @@ describe('ng2 largetable benchmark', function() {
|
||||||
['interpolation', 'interpolationAttr', 'interpolationFn'].forEach(function(benchmarkType) {
|
['interpolation', 'interpolationAttr', 'interpolationFn'].forEach(function(benchmarkType) {
|
||||||
it('should log the ng stats with: ' + benchmarkType, function(done) {
|
it('should log the ng stats with: ' + benchmarkType, function(done) {
|
||||||
console.log('executing for type', benchmarkType);
|
console.log('executing for type', benchmarkType);
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||||
id: 'ng2.largetable.' + benchmarkType,
|
id: 'ng2.largetable.' + benchmarkType,
|
||||||
params: [
|
params: [
|
||||||
{name: 'rows', value: 20, scale: 'sqrt'},
|
{name: 'rows', value: 20, scale: 'sqrt'},
|
||||||
{name: 'columns', value: 20, scale: 'sqrt'},
|
{name: 'columns', value: 20, scale: 'sqrt'},
|
||||||
{name: 'benchmarkType', value: benchmarkType}
|
{name: 'benchmarkType', value: benchmarkType}
|
||||||
]
|
]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should log the baseline stats', function(done) {
|
it('should log the baseline stats', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||||
id: 'baseline.largetable',
|
id: 'baseline.largetable',
|
||||||
params: [
|
params: [
|
||||||
{name: 'rows', value: 100, scale: 'sqrt'},
|
{name: 'rows', value: 100, scale: 'sqrt'},
|
||||||
{name: 'columns', value: 20, scale: 'sqrt'},
|
{name: 'columns', value: 20, scale: 'sqrt'},
|
||||||
{name: 'benchmarkType', value: 'baseline'}
|
{name: 'benchmarkType', value: 'baseline'}
|
||||||
]
|
]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
/// <reference path="../../angular2/typings/angular-protractor/angular-protractor.d.ts" />
|
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 naive infinite scroll benchmark', function() {
|
describe('ng2 naive infinite scroll benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/naive_infinite_scroll/index.html';
|
var URL = 'benchmarks/src/naive_infinite_scroll/index.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
[1, 2, 4].forEach(function(appSize) {
|
[1, 2, 4].forEach(function(appSize) {
|
||||||
it('should run scroll benchmark and collect stats for appSize = ' + appSize, function(done) {
|
it('should run scroll benchmark and collect stats for appSize = ' + appSize, function(done) {
|
||||||
perfUtil.runBenchmark({
|
runBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
id: 'ng2.naive_infinite_scroll',
|
id: 'ng2.naive_infinite_scroll',
|
||||||
work: function() {
|
work: function() {
|
||||||
$('#reset-btn').click();
|
$('#reset-btn').click();
|
||||||
$('#run-btn').click();
|
$('#run-btn').click();
|
||||||
browser.wait(() => {
|
browser.wait(() => {
|
||||||
return $('#done').getText().then(function() { return true; },
|
return $('#done').getText().then(function() { return true; },
|
||||||
function() { return false; });
|
function() { return false; });
|
||||||
}, 10000);
|
}, 10000);
|
||||||
},
|
},
|
||||||
params: [
|
params: [
|
||||||
{name: 'appSize', value: appSize},
|
{name: 'appSize', value: appSize},
|
||||||
{name: 'iterationCount', value: 20, scale: 'linear'},
|
{name: 'iterationCount', value: 20, scale: 'linear'},
|
||||||
{name: 'scrollIncrement', value: 40}
|
{name: 'scrollIncrement', value: 40}
|
||||||
]
|
]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
/// <reference path="../../angular2/typings/angular-protractor/angular-protractor.d.ts" />
|
|
||||||
import {afterEach, describe, expect, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
|
||||||
|
|
||||||
describe('ng2 naive infinite scroll benchmark', function() {
|
describe('ng2 naive infinite scroll benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/naive_infinite_scroll/index.html?appSize=3';
|
var URL = 'benchmarks/src/naive_infinite_scroll/index.html?appSize=3';
|
||||||
|
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should not throw errors', function() {
|
it('should not throw errors', function() {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
@ -20,7 +16,8 @@ describe('ng2 naive infinite scroll benchmark', function() {
|
||||||
|
|
||||||
var count =
|
var count =
|
||||||
function(selector) {
|
function(selector) {
|
||||||
return browser.executeScript(`return document.querySelectorAll("${ selector }").length;`);
|
return browser.executeScript(`return ` +
|
||||||
|
`document.querySelectorAll("${ selector }").length;`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clickFirstOf =
|
var clickFirstOf =
|
||||||
|
@ -30,24 +27,25 @@ describe('ng2 naive infinite scroll benchmark', function() {
|
||||||
|
|
||||||
var firstTextOf =
|
var firstTextOf =
|
||||||
function(selector) {
|
function(selector) {
|
||||||
return browser.executeScript(`return document.querySelector("${ selector }").innerText;`);
|
return browser.executeScript(`return ` +
|
||||||
|
`document.querySelector("${ selector }").innerText;`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure rows are rendered
|
// Make sure rows are rendered
|
||||||
count(allScrollItems)
|
count(allScrollItems)
|
||||||
.then(function(c) { expect(c).toBe(expectedRowCount); });
|
.then(function(c) { expect(c).toEqual(expectedRowCount); });
|
||||||
|
|
||||||
// Make sure cells are rendered
|
// Make sure cells are rendered
|
||||||
count(cells).then(function(c) { expect(c).toBe(expectedRowCount * expectedCellsPerRow); });
|
count(cells).then(function(c) { expect(c).toEqual(expectedRowCount * expectedCellsPerRow); });
|
||||||
|
|
||||||
// Click on first enabled button and verify stage changes
|
// Click on first enabled button and verify stage changes
|
||||||
firstTextOf(`${ stageButtons }:enabled`)
|
firstTextOf(`${ stageButtons }:enabled`)
|
||||||
.then(function(text) {
|
.then(function(text) {
|
||||||
expect(text).toBe('Pitched');
|
expect(text).toEqual('Pitched');
|
||||||
clickFirstOf(`${ stageButtons }:enabled`)
|
clickFirstOf(`${ stageButtons }:enabled`)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
firstTextOf(`${ stageButtons }:enabled`)
|
firstTextOf(`${ stageButtons }:enabled`)
|
||||||
.then(function(text) { expect(text).toBe('Won'); })
|
.then(function(text) { expect(text).toEqual('Won'); })
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,42 +1,36 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 selector benchmark', function() {
|
describe('ng2 selector benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/compiler/selector_benchmark.html';
|
var URL = 'benchmarks/src/compiler/selector_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log parse stats', function(done) {
|
it('should log parse stats', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#parse'],
|
buttons: ['#parse'],
|
||||||
id: 'ng2.selector.parse',
|
id: 'ng2.selector.parse',
|
||||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log addSelectable stats', function(done) {
|
it('should log addSelectable stats', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#addSelectable'],
|
buttons: ['#addSelectable'],
|
||||||
id: 'ng2.selector.addSelectable',
|
id: 'ng2.selector.addSelectable',
|
||||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log match stats', function(done) {
|
it('should log match stats', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#match'],
|
buttons: ['#match'],
|
||||||
id: 'ng2.selector.match',
|
id: 'ng2.selector.match',
|
||||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,65 +1,54 @@
|
||||||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
|
||||||
|
|
||||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
|
||||||
|
|
||||||
describe('ng2 tree benchmark', function() {
|
describe('ng2 tree benchmark', function() {
|
||||||
|
|
||||||
var URL = 'benchmarks/src/tree/tree_benchmark.html';
|
var URL = 'benchmarks/src/tree/tree_benchmark.html';
|
||||||
|
|
||||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should log the ng stats with viewcache', function(done) {
|
it('should log the ng stats with viewcache', function(done) {
|
||||||
perfUtil
|
runClickBenchmark({
|
||||||
.runClickBenchmark({
|
url: URL,
|
||||||
url: URL,
|
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
id: 'ng2.tree.create.viewcache',
|
||||||
id: 'ng2.tree.create.viewcache',
|
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
||||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
}).then(done, done.fail);
|
||||||
})
|
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the ng stats without viewcache', function(done) {
|
it('should log the ng stats without viewcache', function(done) {
|
||||||
perfUtil
|
runClickBenchmark({
|
||||||
.runClickBenchmark({
|
url: URL,
|
||||||
url: URL,
|
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
id: 'ng2.tree.create.plain',
|
||||||
id: 'ng2.tree.create.plain',
|
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'false'}]
|
||||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'false'}]
|
}).then(done, done.fail);
|
||||||
})
|
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the ng stats (update)', function(done) {
|
it('should log the ng stats (update)', function(done) {
|
||||||
perfUtil
|
runClickBenchmark({
|
||||||
.runClickBenchmark({
|
url: URL,
|
||||||
url: URL,
|
buttons: ['#ng2CreateDom'],
|
||||||
buttons: ['#ng2CreateDom'],
|
id: 'ng2.tree.update',
|
||||||
id: 'ng2.tree.update',
|
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
||||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
}).then(done, done.fail);
|
||||||
})
|
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the baseline stats', function(done) {
|
it('should log the baseline stats', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||||
id: 'baseline.tree.create',
|
id: 'baseline.tree.create',
|
||||||
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log the baseline stats (update)', function(done) {
|
it('should log the baseline stats (update)', function(done) {
|
||||||
perfUtil.runClickBenchmark({
|
runClickBenchmark({
|
||||||
url: URL,
|
url: URL,
|
||||||
buttons: ['#baselineCreateDom'],
|
buttons: ['#baselineCreateDom'],
|
||||||
id: 'baseline.tree.update',
|
id: 'baseline.tree.update',
|
||||||
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
||||||
})
|
}).then(done, done.fail);
|
||||||
.then(done, done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {Parser, Lexer, DynamicChangeDetection} from 'angular2/change_detection';
|
||||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||||
|
|
||||||
|
import * as viewModule from 'angular2/src/core/annotations_impl/view';
|
||||||
import {Component, Directive, View} from 'angular2/angular2';
|
import {Component, Directive, View} from 'angular2/angular2';
|
||||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||||
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
|
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
|
||||||
|
@ -113,10 +114,10 @@ class MultipleTemplateResolver extends TemplateResolver {
|
||||||
MapWrapper.set(this._cache, component, ListWrapper.join(multiplier, ''));
|
MapWrapper.set(this._cache, component, ListWrapper.join(multiplier, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(component: Type): View {
|
resolve(component: Type): viewModule.View {
|
||||||
var view = super.resolve(component);
|
var view = super.resolve(component);
|
||||||
var myView =
|
var myView = new viewModule.View(
|
||||||
new View({template: MapWrapper.get(this._cache, component), directives: view.directives});
|
{template:<string>MapWrapper.get(this._cache, component), directives: view.directives});
|
||||||
return myView;
|
return myView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,23 @@ export function main() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Component({selector: 'dummy'})
|
||||||
|
@View({template: `<div></div>`})
|
||||||
|
class DummyComponent {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Directive({selector: '[dummy-decorator]'})
|
||||||
|
class DummyDirective {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'dynamic-dummy'})
|
||||||
|
class DynamicDummy {
|
||||||
|
constructor(loader: DynamicComponentLoader, location: ElementRef) {
|
||||||
|
loader.loadIntoExistingLocation(DummyComponent, location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({selector: 'app'})
|
@Component({selector: 'app'})
|
||||||
@View({
|
@View({
|
||||||
directives: [NgIf, NgFor, DummyComponent, DummyDirective, DynamicDummy],
|
directives: [NgIf, NgFor, DummyComponent, DummyDirective, DynamicDummy],
|
||||||
|
@ -60,7 +77,7 @@ export function main() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ng-if="testingWithDirectives">
|
<div *ng-if="testingWithDirectives">
|
||||||
<dummy dummy-decorator *ng-for="#i of list"></dummy>
|
<dummy [dummy-decorator] *ng-for="#i of list"></dummy>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ng-if="testingDynamicComponents">
|
<div *ng-if="testingDynamicComponents">
|
||||||
|
@ -69,7 +86,7 @@ export function main() {
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
class AppComponent {
|
class AppComponent {
|
||||||
list: List;
|
list: List<any>;
|
||||||
testingPlainComponents: boolean;
|
testingPlainComponents: boolean;
|
||||||
testingWithDirectives: boolean;
|
testingWithDirectives: boolean;
|
||||||
testingDynamicComponents: boolean;
|
testingDynamicComponents: boolean;
|
||||||
|
@ -98,19 +115,3 @@ class AppComponent {
|
||||||
this.testingDynamicComponents = true;
|
this.testingDynamicComponents = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'dummy'})
|
|
||||||
@View({template: `<div></div>`})
|
|
||||||
class DummyComponent {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Directive({selector: '[dummy-decorator]'})
|
|
||||||
class DummyDirective {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({selector: 'dynamic-dummy'})
|
|
||||||
class DynamicDummy {
|
|
||||||
constructor(loader: DynamicComponentLoader, location: ElementRef) {
|
|
||||||
loader.loadIntoExistingLocation(DummyComponent, location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,7 +9,9 @@ import {window, document, gc} from 'angular2/src/facade/browser';
|
||||||
import {
|
import {
|
||||||
getIntParameter,
|
getIntParameter,
|
||||||
getStringParameter,
|
getStringParameter,
|
||||||
bindAction
|
bindAction,
|
||||||
|
windowProfile,
|
||||||
|
windowProfileEnd
|
||||||
} from 'angular2/src/test_lib/benchmark_util';
|
} from 'angular2/src/test_lib/benchmark_util';
|
||||||
|
|
||||||
import {NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/directives';
|
import {NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/directives';
|
||||||
|
@ -18,7 +20,7 @@ import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
import {bind} from 'angular2/di';
|
import {bind} from 'angular2/di';
|
||||||
import {Inject} from 'angular2/src/di/annotations_impl';
|
import {Inject} from 'angular2/src/di/decorators';
|
||||||
|
|
||||||
export const BENCHMARK_TYPE = 'LargetableComponent.benchmarkType';
|
export const BENCHMARK_TYPE = 'LargetableComponent.benchmarkType';
|
||||||
export const LARGETABLE_ROWS = 'LargetableComponent.rows';
|
export const LARGETABLE_ROWS = 'LargetableComponent.rows';
|
||||||
|
@ -73,7 +75,7 @@ export function main() {
|
||||||
|
|
||||||
function profile(create, destroy, name) {
|
function profile(create, destroy, name) {
|
||||||
return function() {
|
return function() {
|
||||||
window.console.profile(name + ' w GC');
|
windowProfile(name + ' w GC');
|
||||||
var duration = 0;
|
var duration = 0;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
while (count++ < 150) {
|
while (count++ < 150) {
|
||||||
|
@ -83,10 +85,10 @@ export function main() {
|
||||||
duration += window.performance.now() - start;
|
duration += window.performance.now() - start;
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
window.console.profileEnd(name + ' w GC');
|
windowProfileEnd(name + ' w GC');
|
||||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||||
|
|
||||||
window.console.profile(name + ' w/o GC');
|
windowProfile(name + ' w/o GC');
|
||||||
duration = 0;
|
duration = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
while (count++ < 150) {
|
while (count++ < 150) {
|
||||||
|
@ -95,7 +97,7 @@ export function main() {
|
||||||
duration += window.performance.now() - start;
|
duration += window.performance.now() - start;
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
window.console.profileEnd(name + ' w/o GC');
|
windowProfileEnd(name + ' w/o GC');
|
||||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -187,7 +189,8 @@ class BaseLineLargetableComponent {
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
this.table = DOM.clone(BASELINE_LARGETABLE_TEMPLATE.content.firstChild);
|
this.table = DOM.clone(BASELINE_LARGETABLE_TEMPLATE.content.firstChild);
|
||||||
var shadowRoot = DOM.createShadowRoot(this.element) DOM.appendChild(shadowRoot, this.table);
|
var shadowRoot = DOM.createShadowRoot(this.element);
|
||||||
|
DOM.appendChild(shadowRoot, this.table);
|
||||||
}
|
}
|
||||||
update(tbody) {
|
update(tbody) {
|
||||||
var oldBody = DOM.querySelector(this.table, 'tbody');
|
var oldBody = DOM.querySelector(this.table, 'tbody');
|
||||||
|
@ -212,43 +215,33 @@ class CellData {
|
||||||
iFn() { return this.i; }
|
iFn() { return this.i; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'app'})
|
|
||||||
@View({
|
|
||||||
directives: [LargetableComponent],
|
|
||||||
template: `<largetable [data]='data' [benchmarkType]='benchmarkType'></largetable>`
|
|
||||||
})
|
|
||||||
class AppComponent {
|
|
||||||
data;
|
|
||||||
benchmarkType: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({selector: 'largetable', properties: ['data', 'benchmarkType']})
|
@Component({selector: 'largetable', properties: ['data', 'benchmarkType']})
|
||||||
@View({
|
@View({
|
||||||
directives: [NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault],
|
directives: [NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault],
|
||||||
template: `
|
template: `
|
||||||
<table [ng-switch]="benchmarkType">
|
<table [ng-switch]="benchmarkType">
|
||||||
<tbody template="switch-when 'interpolation'">
|
<tbody template="ng-switch-when 'interpolation'">
|
||||||
<tr template="for #row of data">
|
<tr template="ng-for #row of data">
|
||||||
<td template="for #column of row">
|
<td template="ng-for #column of row">
|
||||||
{{column.i}}:{{column.j}}|
|
{{column.i}}:{{column.j}}|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tbody template="switch-when 'interpolationAttr'">
|
<tbody template="ng-switch-when 'interpolationAttr'">
|
||||||
<tr template="for #row of data">
|
<tr template="ng-for #row of data">
|
||||||
<td template="for #column of row" i="{{column.i}}" j="{{column.j}}">
|
<td template="ng-for #column of row" i="{{column.i}}" j="{{column.j}}">
|
||||||
i,j attrs
|
i,j attrs
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tbody template="switch-when 'interpolationFn'">
|
<tbody template="ng-switch-when 'interpolationFn'">
|
||||||
<tr template="for #row of data">
|
<tr template="ng-for #row of data">
|
||||||
<td template="for #column of row">
|
<td template="ng-for #column of row">
|
||||||
{{column.iFn()}}:{{column.jFn()}}|
|
{{column.iFn()}}:{{column.jFn()}}|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tbody template="switch-default">
|
<tbody template="ng-switch-default">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<em>{{benchmarkType}} not yet implemented</em>
|
<em>{{benchmarkType}} not yet implemented</em>
|
||||||
|
@ -262,10 +255,20 @@ class LargetableComponent {
|
||||||
benchmarkType: string;
|
benchmarkType: string;
|
||||||
rows: number;
|
rows: number;
|
||||||
columns: number;
|
columns: number;
|
||||||
constructor(@Inject(BENCHMARK_TYPE) benchmarkType: BENCHMARK_TYPE,
|
constructor(@Inject(BENCHMARK_TYPE) benchmarkType, @Inject(LARGETABLE_ROWS) rows,
|
||||||
@Inject(LARGETABLE_ROWS) rows: LARGETABLE_ROWS, @Inject(LARGETABLE_COLS) columns) {
|
@Inject(LARGETABLE_COLS) columns) {
|
||||||
this.benchmarkType = benchmarkType;
|
this.benchmarkType = benchmarkType;
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'app'})
|
||||||
|
@View({
|
||||||
|
directives: [LargetableComponent],
|
||||||
|
template: `<largetable [data]='data' [benchmarkType]='benchmarkType'></largetable>`
|
||||||
|
})
|
||||||
|
class AppComponent {
|
||||||
|
data;
|
||||||
|
benchmarkType: string;
|
||||||
|
}
|
||||||
|
|
|
@ -10,14 +10,16 @@ import {window, document, gc} from 'angular2/src/facade/browser';
|
||||||
import {
|
import {
|
||||||
getIntParameter,
|
getIntParameter,
|
||||||
getStringParameter,
|
getStringParameter,
|
||||||
bindAction
|
bindAction,
|
||||||
|
windowProfile,
|
||||||
|
windowProfileEnd
|
||||||
} from 'angular2/src/test_lib/benchmark_util';
|
} from 'angular2/src/test_lib/benchmark_util';
|
||||||
import {NgIf} from 'angular2/directives';
|
import {NgIf} from 'angular2/directives';
|
||||||
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||||
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
|
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
|
||||||
import {bind} from 'angular2/di';
|
import {bind, Binding} from 'angular2/di';
|
||||||
|
|
||||||
function createBindings(): List {
|
function createBindings(): List<Binding> {
|
||||||
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1;
|
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1;
|
||||||
return [bind(APP_VIEW_POOL_CAPACITY).toValue(viewCacheCapacity)];
|
return [bind(APP_VIEW_POOL_CAPACITY).toValue(viewCacheCapacity)];
|
||||||
}
|
}
|
||||||
|
@ -53,7 +55,7 @@ export function main() {
|
||||||
|
|
||||||
function profile(create, destroy, name) {
|
function profile(create, destroy, name) {
|
||||||
return function() {
|
return function() {
|
||||||
window.console.profile(name + ' w GC');
|
windowProfile(name + ' w GC');
|
||||||
var duration = 0;
|
var duration = 0;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
while (count++ < 150) {
|
while (count++ < 150) {
|
||||||
|
@ -63,10 +65,10 @@ export function main() {
|
||||||
duration += window.performance.now() - start;
|
duration += window.performance.now() - start;
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
window.console.profileEnd(name + ' w GC');
|
windowProfileEnd(name + ' w GC');
|
||||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||||
|
|
||||||
window.console.profile(name + ' w/o GC');
|
windowProfile(name + ' w/o GC');
|
||||||
duration = 0;
|
duration = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
while (count++ < 150) {
|
while (count++ < 150) {
|
||||||
|
@ -75,7 +77,7 @@ export function main() {
|
||||||
duration += window.performance.now() - start;
|
duration += window.performance.now() - start;
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
window.console.profileEnd(name + ' w/o GC');
|
windowProfileEnd(name + ' w/o GC');
|
||||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -218,6 +220,16 @@ class BaseLineIf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'tree', properties: ['data']})
|
||||||
|
@View({
|
||||||
|
directives: [TreeComponent, NgIf],
|
||||||
|
template:
|
||||||
|
`<span> {{data.value}} <span template='ng-if data.right != null'><tree [data]='data.right'></tree></span><span template='ng-if data.left != null'><tree [data]='data.left'></tree></span></span>`
|
||||||
|
})
|
||||||
|
class TreeComponent {
|
||||||
|
data: TreeNode;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({selector: 'app'})
|
@Component({selector: 'app'})
|
||||||
@View({directives: [TreeComponent], template: `<tree [data]='initData'></tree>`})
|
@View({directives: [TreeComponent], template: `<tree [data]='initData'></tree>`})
|
||||||
class AppComponent {
|
class AppComponent {
|
||||||
|
@ -228,13 +240,3 @@ class AppComponent {
|
||||||
this.initData = new TreeNode('', null, null);
|
this.initData = new TreeNode('', null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'tree', properties: ['data']})
|
|
||||||
@View({
|
|
||||||
directives: [TreeComponent, NgIf],
|
|
||||||
template:
|
|
||||||
`<span> {{data.value}} <span template='ng-if data.right != null'><tree [data]='data.right'></tree></span><span template='ng-if data.left != null'><tree [data]='data.left'></tree></span></span>`
|
|
||||||
})
|
|
||||||
class TreeComponent {
|
|
||||||
data: TreeNode;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue