feat(benchmark): make view cache a parameter to the tree benchmark

This commit is contained in:
Tobias Bosch 2015-04-10 13:23:34 -07:00
parent e34146fc14
commit 6ce085a21a
6 changed files with 36 additions and 13 deletions

View File

@ -13,7 +13,7 @@ export const VIEW_POOL_CAPACITY = 'ViewFactory.viewPoolCapacity';
@Injectable()
export class ViewFactory {
_poolCapacityPerProtoView:number;
_pooledViewsPerProtoView:Map<vieModule.ProtoView, List<viewModule.AppView>>;
_pooledViewsPerProtoView:Map<viewModule.AppProtoView, List<viewModule.AppView>>;
constructor(@Inject(VIEW_POOL_CAPACITY) poolCapacityPerProtoView) {
this._poolCapacityPerProtoView = poolCapacityPerProtoView;

View File

@ -27,7 +27,6 @@ export function main() {
describe('caching', () => {
it('should support multiple AppProtoViews', () => {
var capacity;
var pv1 = createPv();
var pv2 = createPv();
var vf = createViewFactory({ capacity: 2 });
@ -41,7 +40,6 @@ export function main() {
});
it('should reuse the newest view that has been returned', () => {
var capacity;
var pv = createPv();
var vf = createViewFactory({ capacity: 2 });
var view1 = vf.getView(pv);
@ -53,7 +51,6 @@ export function main() {
});
it('should not add views when the capacity has been reached', () => {
var capacity;
var pv = createPv();
var vf = createViewFactory({ capacity: 2 });
var view1 = vf.getView(pv);

View File

@ -29,7 +29,6 @@ export function main() {
describe('caching', () => {
it('should support multiple RenderProtoViews', () => {
var capacity;
var pv1 = createPv();
var pv2 = createPv();
var vf = createViewFactory({ capacity: 2 });
@ -43,7 +42,6 @@ export function main() {
});
it('should reuse the newest view that has been returned', () => {
var capacity;
var pv = createPv();
var vf = createViewFactory({ capacity: 2 });
var view1 = vf.getView(pv);
@ -55,7 +53,6 @@ export function main() {
});
it('should not add views when the capacity has been reached', () => {
var capacity;
var pv = createPv();
var vf = createViewFactory({ capacity: 2 });
var view1 = vf.getView(pv);

View File

@ -6,13 +6,28 @@ describe('ng2 tree benchmark', function () {
afterEach(perfUtil.verifyNoBrowserErrors);
it('should log the ng stats', function(done) {
it('should log the ng stats with viewcache', function(done) {
perfUtil.runClickBenchmark({
url: URL,
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
id: 'ng2.tree',
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);
});
@ -24,6 +39,8 @@ describe('ng2 tree benchmark', function () {
id: 'ng2.tree.update',
params: [{
name: 'depth', value: 9, scale: 'log2'
},{
name: 'viewcache', value: 'true'
}]
}).then(done, done.fail);
});
@ -32,7 +49,7 @@ describe('ng2 tree benchmark', function () {
perfUtil.runClickBenchmark({
url: URL,
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
id: 'baseline.tree',
id: 'baseline.tree.create',
params: [{
name: 'depth', value: 9, scale: 'log2'
}]
@ -43,7 +60,7 @@ describe('ng2 tree benchmark', function () {
perfUtil.runClickBenchmark({
url: URL,
buttons: ['#baselineCreateDom'],
id: 'baseline.tree',
id: 'baseline.tree.update',
params: [{
name: 'depth', value: 9, scale: 'log2'
}]

View File

@ -7,6 +7,14 @@
Depth:
<input type="number" name="depth" placeholder="depth" value="9">
<br>
Use Viewcache:
<label>
Yes<input type="radio" name="viewcache" placeholder="use viewcache" value="true" checked="checked">
</label>
<label>
No<input type="radio" name="viewcache" placeholder="use viewcache" value="false">
</label>
<br>
<button>Apply</button>
</form>

View File

@ -24,7 +24,7 @@ import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabil
import {DOM} from 'angular2/src/dom/dom_adapter';
import {isPresent} from 'angular2/src/facade/lang';
import {window, document, gc} from 'angular2/src/facade/browser';
import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';
import {getIntParameter, getStringParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';
import {XHR} from 'angular2/src/services/xhr';
import {XHRImpl} from 'angular2/src/services/xhr_impl';
@ -42,7 +42,11 @@ import * as rvf from 'angular2/src/render/dom/view/view_factory';
import {Inject, bind} from 'angular2/di';
function createBindings():List {
return [bind(VIEW_POOL_CAPACITY).toValue(100000)];
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1;
return [
bind(rvf.VIEW_POOL_CAPACITY).toValue(viewCacheCapacity),
bind(VIEW_POOL_CAPACITY).toValue(viewCacheCapacity)
];
}
function setupReflector() {