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
|
|
@ -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 {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 change detection benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/change_detection/change_detection_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log ng stats (dynamic, reads)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionDynamicReads'],
|
||||
id: 'ng2.changeDetection.dynamic.reads',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionDynamicReads'],
|
||||
id: 'ng2.changeDetection.dynamic.reads',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log ng stats (dynamic, writes)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionDynamicWrites'],
|
||||
id: 'ng2.changeDetection.dynamic.writes',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionDynamicWrites'],
|
||||
id: 'ng2.changeDetection.dynamic.writes',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log ng stats (jit, reads)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionJitReads'],
|
||||
id: 'ng2.changeDetection.jit.reads',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionJitReads'],
|
||||
id: 'ng2.changeDetection.jit.reads',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log ng stats (jit, writes)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionJitWrites'],
|
||||
id: 'ng2.changeDetection.jit.writes',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2ChangeDetectionJitWrites'],
|
||||
id: 'ng2.changeDetection.jit.writes',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log baseline stats (create)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineChangeDetectionReads'],
|
||||
id: 'baseline.changeDetection.reads',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineChangeDetectionReads'],
|
||||
id: 'baseline.changeDetection.reads',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log baseline stats (update)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineChangeDetectionWrites'],
|
||||
id: 'baseline.changeDetection.writes',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineChangeDetectionWrites'],
|
||||
id: 'baseline.changeDetection.writes',
|
||||
params: [
|
||||
{name: 'numberOfChecks', value: 900000},
|
||||
{name: 'iterations', value: 20, scale: 'linear'}
|
||||
],
|
||||
microMetrics: {'detectChangesAvg': 'avg time to detect changes (ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,39 +1,33 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
/// <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');
|
||||
import {runBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 compiler benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/compiler/compiler_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log withBindings stats', function(done) {
|
||||
perfUtil.runBenchmark({
|
||||
url: URL,
|
||||
id: 'ng2.compile.withBindings',
|
||||
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
||||
work: function() {
|
||||
browser.executeScript('document.querySelector("#compileWithBindings").click()');
|
||||
browser.sleep(500);
|
||||
}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runBenchmark({
|
||||
url: URL,
|
||||
id: 'ng2.compile.withBindings',
|
||||
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
||||
work: function() {
|
||||
browser.executeScript('document.querySelector("#compileWithBindings").click()');
|
||||
browser.sleep(500);
|
||||
}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log noBindings stats', function(done) {
|
||||
perfUtil.runBenchmark({
|
||||
url: URL,
|
||||
id: 'ng2.compile.noBindings',
|
||||
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
||||
work: function() {
|
||||
browser.executeScript('document.querySelector("#compileNoBindings").click()');
|
||||
browser.sleep(500);
|
||||
}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runBenchmark({
|
||||
url: URL,
|
||||
id: 'ng2.compile.noBindings',
|
||||
params: [{name: 'elements', value: 150, scale: 'linear'}],
|
||||
work: function() {
|
||||
browser.executeScript('document.querySelector("#compileNoBindings").click()');
|
||||
browser.sleep(500);
|
||||
}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 cost benchmark', function() {
|
||||
|
||||
|
@ -10,35 +7,32 @@ describe('ng2 cost benchmark', function() {
|
|||
// Number of components to create in a single iteration
|
||||
var benchmarkSize = 200;
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log stats for baseline (plain components)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#reset', '#createPlainComponents'],
|
||||
id: 'ng2.costs.baseline',
|
||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#reset', '#createPlainComponents'],
|
||||
id: 'ng2.costs.baseline',
|
||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log stats for components with decorators', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#reset', '#createComponentsWithDirectives'],
|
||||
id: 'ng2.costs.decorators',
|
||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#reset', '#createComponentsWithDirectives'],
|
||||
id: 'ng2.costs.decorators',
|
||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log stats for dynamic components', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#reset', '#createDynamicComponents'],
|
||||
id: 'ng2.costs.dynamic',
|
||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#reset', '#createDynamicComponents'],
|
||||
id: 'ng2.costs.dynamic',
|
||||
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,56 +1,49 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 di benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/di/di_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log the stats for getByToken', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#getByToken'],
|
||||
id: 'ng2.di.getByToken',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#getByToken'],
|
||||
id: 'ng2.di.getByToken',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the stats for getByKey', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#getByKey'],
|
||||
id: 'ng2.di.getByKey',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#getByKey'],
|
||||
id: 'ng2.di.getByKey',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for injection (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the stats for getChild', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#getChild'],
|
||||
id: 'ng2.di.getChild',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for getChild (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#getChild'],
|
||||
id: 'ng2.di.getChild',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for getChild (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the stats for instantiate', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#instantiate'],
|
||||
id: 'ng2.di.instantiate',
|
||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for instantiate (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#instantiate'],
|
||||
id: 'ng2.di.instantiate',
|
||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for instantiate (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -58,28 +51,26 @@ describe('ng2 di benchmark', function() {
|
|||
* of binding types: Type, unresolved, unflattened.
|
||||
*/
|
||||
it('should log the stats for createVariety', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#createVariety'],
|
||||
id: 'ng2.di.createVariety',
|
||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for createVariety (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#createVariety'],
|
||||
id: 'ng2.di.createVariety',
|
||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for createVariety (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
/**
|
||||
* Same as 'createVariety' benchmark but operates on fully resolved bindings.
|
||||
*/
|
||||
it('should log the stats for createVarietyResolved', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#createVarietyResolved'],
|
||||
id: 'ng2.di.createVarietyResolved',
|
||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for createVarietyResolved (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#createVarietyResolved'],
|
||||
id: 'ng2.di.createVarietyResolved',
|
||||
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
||||
microMetrics: {'injectAvg': 'avg time for createVarietyResolved (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,34 +1,29 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 element injector benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/element_injector/element_injector_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log the stats for instantiate', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#instantiate'],
|
||||
id: 'ng2.elementInjector.instantiate',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#instantiate'],
|
||||
id: 'ng2.elementInjector.instantiate',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the stats for hydrate', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#hydrate'],
|
||||
id: 'ng2.elementInjector.hydrate',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#hydrate'],
|
||||
id: 'ng2.elementInjector.hydrate',
|
||||
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
||||
microMetrics: {'instantiateAvg': 'avg time for injection (in ms)'}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 largetable benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/largetable/largetable_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
// Not yet implemented:
|
||||
// 'ngBind',
|
||||
|
@ -19,33 +16,31 @@ describe('ng2 largetable benchmark', function() {
|
|||
['interpolation', 'interpolationAttr', 'interpolationFn'].forEach(function(benchmarkType) {
|
||||
it('should log the ng stats with: ' + benchmarkType, function(done) {
|
||||
console.log('executing for type', benchmarkType);
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.largetable.' + benchmarkType,
|
||||
params: [
|
||||
{name: 'rows', value: 20, scale: 'sqrt'},
|
||||
{name: 'columns', value: 20, scale: 'sqrt'},
|
||||
{name: 'benchmarkType', value: benchmarkType}
|
||||
]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.largetable.' + benchmarkType,
|
||||
params: [
|
||||
{name: 'rows', value: 20, scale: 'sqrt'},
|
||||
{name: 'columns', value: 20, scale: 'sqrt'},
|
||||
{name: 'benchmarkType', value: benchmarkType}
|
||||
]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should log the baseline stats', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||
id: 'baseline.largetable',
|
||||
params: [
|
||||
{name: 'rows', value: 100, scale: 'sqrt'},
|
||||
{name: 'columns', value: 20, scale: 'sqrt'},
|
||||
{name: 'benchmarkType', value: 'baseline'}
|
||||
]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||
id: 'baseline.largetable',
|
||||
params: [
|
||||
{name: 'rows', value: 100, scale: 'sqrt'},
|
||||
{name: 'columns', value: 20, scale: 'sqrt'},
|
||||
{name: 'benchmarkType', value: 'baseline'}
|
||||
]
|
||||
}).then(done, done.fail);
|
||||
;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,35 +1,30 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
/// <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');
|
||||
import {runBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 naive infinite scroll benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/naive_infinite_scroll/index.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
[1, 2, 4].forEach(function(appSize) {
|
||||
it('should run scroll benchmark and collect stats for appSize = ' + appSize, function(done) {
|
||||
perfUtil.runBenchmark({
|
||||
url: URL,
|
||||
id: 'ng2.naive_infinite_scroll',
|
||||
work: function() {
|
||||
$('#reset-btn').click();
|
||||
$('#run-btn').click();
|
||||
browser.wait(() => {
|
||||
return $('#done').getText().then(function() { return true; },
|
||||
function() { return false; });
|
||||
}, 10000);
|
||||
},
|
||||
params: [
|
||||
{name: 'appSize', value: appSize},
|
||||
{name: 'iterationCount', value: 20, scale: 'linear'},
|
||||
{name: 'scrollIncrement', value: 40}
|
||||
]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runBenchmark({
|
||||
url: URL,
|
||||
id: 'ng2.naive_infinite_scroll',
|
||||
work: function() {
|
||||
$('#reset-btn').click();
|
||||
$('#run-btn').click();
|
||||
browser.wait(() => {
|
||||
return $('#done').getText().then(function() { return true; },
|
||||
function() { return false; });
|
||||
}, 10000);
|
||||
},
|
||||
params: [
|
||||
{name: 'appSize', value: appSize},
|
||||
{name: 'iterationCount', value: 20, scale: 'linear'},
|
||||
{name: 'scrollIncrement', value: 40}
|
||||
]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
/// <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');
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||
|
||||
describe('ng2 naive infinite scroll benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/naive_infinite_scroll/index.html?appSize=3';
|
||||
|
||||
afterEach(testUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should not throw errors', function() {
|
||||
browser.get(URL);
|
||||
|
@ -20,7 +16,8 @@ describe('ng2 naive infinite scroll benchmark', function() {
|
|||
|
||||
var count =
|
||||
function(selector) {
|
||||
return browser.executeScript(`return document.querySelectorAll("${ selector }").length;`);
|
||||
return browser.executeScript(`return ` +
|
||||
`document.querySelectorAll("${ selector }").length;`);
|
||||
}
|
||||
|
||||
var clickFirstOf =
|
||||
|
@ -30,24 +27,25 @@ describe('ng2 naive infinite scroll benchmark', function() {
|
|||
|
||||
var firstTextOf =
|
||||
function(selector) {
|
||||
return browser.executeScript(`return document.querySelector("${ selector }").innerText;`);
|
||||
return browser.executeScript(`return ` +
|
||||
`document.querySelector("${ selector }").innerText;`);
|
||||
}
|
||||
|
||||
// Make sure rows are rendered
|
||||
count(allScrollItems)
|
||||
.then(function(c) { expect(c).toBe(expectedRowCount); });
|
||||
.then(function(c) { expect(c).toEqual(expectedRowCount); });
|
||||
|
||||
// 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
|
||||
firstTextOf(`${ stageButtons }:enabled`)
|
||||
.then(function(text) {
|
||||
expect(text).toBe('Pitched');
|
||||
expect(text).toEqual('Pitched');
|
||||
clickFirstOf(`${ stageButtons }:enabled`)
|
||||
.then(function() {
|
||||
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 {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 selector benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/compiler/selector_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log parse stats', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#parse'],
|
||||
id: 'ng2.selector.parse',
|
||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#parse'],
|
||||
id: 'ng2.selector.parse',
|
||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log addSelectable stats', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#addSelectable'],
|
||||
id: 'ng2.selector.addSelectable',
|
||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#addSelectable'],
|
||||
id: 'ng2.selector.addSelectable',
|
||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log match stats', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#match'],
|
||||
id: 'ng2.selector.match',
|
||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#match'],
|
||||
id: 'ng2.selector.match',
|
||||
params: [{name: 'selectors', value: 10000, scale: 'linear'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,65 +1,54 @@
|
|||
/// <reference path="../../angular2/typings/node/node.d.ts" />
|
||||
import {afterEach, describe, it} from 'angular2/test_lib';
|
||||
|
||||
var perfUtil = require('angular2/src/test_lib/perf_util');
|
||||
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
|
||||
|
||||
describe('ng2 tree benchmark', function() {
|
||||
|
||||
var URL = 'benchmarks/src/tree/tree_benchmark.html';
|
||||
|
||||
afterEach(perfUtil.verifyNoBrowserErrors);
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
it('should log the ng stats with viewcache', function(done) {
|
||||
perfUtil
|
||||
.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.tree.create.viewcache',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.tree.create.viewcache',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the ng stats without viewcache', function(done) {
|
||||
perfUtil
|
||||
.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.tree.create.plain',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'false'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.tree.create.plain',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'false'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the ng stats (update)', function(done) {
|
||||
perfUtil
|
||||
.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2CreateDom'],
|
||||
id: 'ng2.tree.update',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#ng2CreateDom'],
|
||||
id: 'ng2.tree.update',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}, {name: 'viewcache', value: 'true'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the baseline stats', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||
id: 'baseline.tree.create',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||
id: 'baseline.tree.create',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the baseline stats (update)', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineCreateDom'],
|
||||
id: 'baseline.tree.update',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
||||
})
|
||||
.then(done, done.fail);
|
||||
runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#baselineCreateDom'],
|
||||
id: 'baseline.tree.update',
|
||||
params: [{name: 'depth', value: 9, scale: 'log2'}]
|
||||
}).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 {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 {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
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, ''));
|
||||
}
|
||||
|
||||
resolve(component: Type): View {
|
||||
resolve(component: Type): viewModule.View {
|
||||
var view = super.resolve(component);
|
||||
var myView =
|
||||
new View({template: MapWrapper.get(this._cache, component), directives: view.directives});
|
||||
var myView = new viewModule.View(
|
||||
{template:<string>MapWrapper.get(this._cache, component), directives: view.directives});
|
||||
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'})
|
||||
@View({
|
||||
directives: [NgIf, NgFor, DummyComponent, DummyDirective, DynamicDummy],
|
||||
|
@ -60,7 +77,7 @@ export function main() {
|
|||
</div>
|
||||
|
||||
<div *ng-if="testingWithDirectives">
|
||||
<dummy dummy-decorator *ng-for="#i of list"></dummy>
|
||||
<dummy [dummy-decorator] *ng-for="#i of list"></dummy>
|
||||
</div>
|
||||
|
||||
<div *ng-if="testingDynamicComponents">
|
||||
|
@ -69,7 +86,7 @@ export function main() {
|
|||
`
|
||||
})
|
||||
class AppComponent {
|
||||
list: List;
|
||||
list: List<any>;
|
||||
testingPlainComponents: boolean;
|
||||
testingWithDirectives: boolean;
|
||||
testingDynamicComponents: boolean;
|
||||
|
@ -98,19 +115,3 @@ class AppComponent {
|
|||
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 {
|
||||
getIntParameter,
|
||||
getStringParameter,
|
||||
bindAction
|
||||
bindAction,
|
||||
windowProfile,
|
||||
windowProfileEnd
|
||||
} from 'angular2/src/test_lib/benchmark_util';
|
||||
|
||||
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 {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 LARGETABLE_ROWS = 'LargetableComponent.rows';
|
||||
|
@ -73,7 +75,7 @@ export function main() {
|
|||
|
||||
function profile(create, destroy, name) {
|
||||
return function() {
|
||||
window.console.profile(name + ' w GC');
|
||||
windowProfile(name + ' w GC');
|
||||
var duration = 0;
|
||||
var count = 0;
|
||||
while (count++ < 150) {
|
||||
|
@ -83,10 +85,10 @@ export function main() {
|
|||
duration += window.performance.now() - start;
|
||||
destroy();
|
||||
}
|
||||
window.console.profileEnd(name + ' w GC');
|
||||
windowProfileEnd(name + ' w GC');
|
||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||
|
||||
window.console.profile(name + ' w/o GC');
|
||||
windowProfile(name + ' w/o GC');
|
||||
duration = 0;
|
||||
count = 0;
|
||||
while (count++ < 150) {
|
||||
|
@ -95,7 +97,7 @@ export function main() {
|
|||
duration += window.performance.now() - start;
|
||||
destroy();
|
||||
}
|
||||
window.console.profileEnd(name + ' w/o GC');
|
||||
windowProfileEnd(name + ' w/o GC');
|
||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||
};
|
||||
}
|
||||
|
@ -187,7 +189,8 @@ class BaseLineLargetableComponent {
|
|||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
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) {
|
||||
var oldBody = DOM.querySelector(this.table, 'tbody');
|
||||
|
@ -212,43 +215,33 @@ class CellData {
|
|||
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']})
|
||||
@View({
|
||||
directives: [NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault],
|
||||
template: `
|
||||
<table [ng-switch]="benchmarkType">
|
||||
<tbody template="switch-when 'interpolation'">
|
||||
<tr template="for #row of data">
|
||||
<td template="for #column of row">
|
||||
<tbody template="ng-switch-when 'interpolation'">
|
||||
<tr template="ng-for #row of data">
|
||||
<td template="ng-for #column of row">
|
||||
{{column.i}}:{{column.j}}|
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody template="switch-when 'interpolationAttr'">
|
||||
<tr template="for #row of data">
|
||||
<td template="for #column of row" i="{{column.i}}" j="{{column.j}}">
|
||||
<tbody template="ng-switch-when 'interpolationAttr'">
|
||||
<tr template="ng-for #row of data">
|
||||
<td template="ng-for #column of row" i="{{column.i}}" j="{{column.j}}">
|
||||
i,j attrs
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody template="switch-when 'interpolationFn'">
|
||||
<tr template="for #row of data">
|
||||
<td template="for #column of row">
|
||||
<tbody template="ng-switch-when 'interpolationFn'">
|
||||
<tr template="ng-for #row of data">
|
||||
<td template="ng-for #column of row">
|
||||
{{column.iFn()}}:{{column.jFn()}}|
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody template="switch-default">
|
||||
<tbody template="ng-switch-default">
|
||||
<tr>
|
||||
<td>
|
||||
<em>{{benchmarkType}} not yet implemented</em>
|
||||
|
@ -262,10 +255,20 @@ class LargetableComponent {
|
|||
benchmarkType: string;
|
||||
rows: number;
|
||||
columns: number;
|
||||
constructor(@Inject(BENCHMARK_TYPE) benchmarkType: BENCHMARK_TYPE,
|
||||
@Inject(LARGETABLE_ROWS) rows: LARGETABLE_ROWS, @Inject(LARGETABLE_COLS) columns) {
|
||||
constructor(@Inject(BENCHMARK_TYPE) benchmarkType, @Inject(LARGETABLE_ROWS) rows,
|
||||
@Inject(LARGETABLE_COLS) columns) {
|
||||
this.benchmarkType = benchmarkType;
|
||||
this.rows = rows;
|
||||
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 {
|
||||
getIntParameter,
|
||||
getStringParameter,
|
||||
bindAction
|
||||
bindAction,
|
||||
windowProfile,
|
||||
windowProfileEnd
|
||||
} from 'angular2/src/test_lib/benchmark_util';
|
||||
import {NgIf} from 'angular2/directives';
|
||||
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||
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;
|
||||
return [bind(APP_VIEW_POOL_CAPACITY).toValue(viewCacheCapacity)];
|
||||
}
|
||||
|
@ -53,7 +55,7 @@ export function main() {
|
|||
|
||||
function profile(create, destroy, name) {
|
||||
return function() {
|
||||
window.console.profile(name + ' w GC');
|
||||
windowProfile(name + ' w GC');
|
||||
var duration = 0;
|
||||
var count = 0;
|
||||
while (count++ < 150) {
|
||||
|
@ -63,10 +65,10 @@ export function main() {
|
|||
duration += window.performance.now() - start;
|
||||
destroy();
|
||||
}
|
||||
window.console.profileEnd(name + ' w GC');
|
||||
windowProfileEnd(name + ' w GC');
|
||||
window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`);
|
||||
|
||||
window.console.profile(name + ' w/o GC');
|
||||
windowProfile(name + ' w/o GC');
|
||||
duration = 0;
|
||||
count = 0;
|
||||
while (count++ < 150) {
|
||||
|
@ -75,7 +77,7 @@ export function main() {
|
|||
duration += window.performance.now() - start;
|
||||
destroy();
|
||||
}
|
||||
window.console.profileEnd(name + ' w/o GC');
|
||||
windowProfileEnd(name + ' w/o GC');
|
||||
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'})
|
||||
@View({directives: [TreeComponent], template: `<tree [data]='initData'></tree>`})
|
||||
class AppComponent {
|
||||
|
@ -228,13 +240,3 @@ class AppComponent {
|
|||
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