Try this code in Firefox and IE7.
You will see that this.callParent([arg1, arg2, arg3]) calls are faster compared to this.callParent(arguments);
FF - 10% faster
IE7 - 100% faster
I suggest making this modification in the Ext code base.
Code:
Ext.define('MyClass', {
test: function(arg1, arg2, arg3) {
}
});
Ext.define('Sub1', {
extend: 'MyClass',
test: function (arg1, arg2, arg3) {
this.callParent(arguments);
}
});
Ext.define('Sub2', {
extend: 'MyClass',
test: function (arg1, arg2, arg3) {
this.callParent([arg1, arg2, arg3]);
}
});
var obj1 = new Sub1(),
obj2 = new Sub2(),
i = 0;
console.time('1');
for(i=0; i<20000; i++) {
obj1.test('123', {}, 123);
}
console.timeEnd('1');
console.time('2');
for(i=0; i<20000; i++) {
obj2.test('123', {}, 123);
}
console.timeEnd('2');
Also, try this code. It's at least 100% faster on IE7
Code:
Ext.define('MyClass', {
test: function() {
}
});
Ext.define('Sub1', {
extend: 'MyClass',
test: function () {
this.callParent(arguments);
}
});
Ext.define('Sub2', {
extend: 'MyClass',
test: function () {
this.callParent();
}
});
var obj1 = new Sub1(),
obj2 = new Sub2(),
i = 0;
console.time('1');
for(i=0; i<20000; i++) {
obj1.test();
}
console.timeEnd('1');
console.time('2');
for(i=0; i<20000; i++) {
obj2.test();
}
console.timeEnd('2');
I see code like this in Ext. I think the bold arguments is not needed.
Code:
enable: function() {
this.callParent(arguments);
var itemsToDisable = this.getChildItemsToDisable(),
length = itemsToDisable.length,
item, i;
for (i = 0; i < length; i++) {
item = itemsToDisable[i];
if (item.resetDisable) {
item.enable();
}
}
}
Results for the 2nd example on IE7
860ms 203ms
828ms 187ms
843ms 172ms
1500ms 218ms
984ms 125ms
1250ms 296ms
344ms 141ms
703ms 125ms
937ms 141ms
547ms 125ms
890ms 219ms