Ext.each vs Native
JavaScript performance comparison
Preparation code
<script src="http://cdn.sencha.com/ext-4.1.1-gpl/ext-all-debug.js">
</script>
<script>
Benchmark.prototype.setup = function() {
var obj = {};
i = 0
doSomething = function() {}
opt = function(object, fn, scope) {
if ('forEach' in Array.prototype && typeof Object.keys === "function") {
Object.keys(object).every(function() {
return (fn.apply(this, arguments) !== false);
}, scope);
} else {
for (var property in object) {
if (object.hasOwnProperty(property)) {
if (fn.call(scope || object, property, object[property], object) === false) {
return;
}
}
}
}
};
scope = {
a: '123'
};
for (i = 0; i < 1000; i++) {
obj['k' + i] = 'val' + i;
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Native for-in Object |
|
pending… |
Native for-in Object without prototype check |
|
pending… |
Ext.Object.each without scope |
|
pending… |
Ext.Object.each with scope |
|
pending… |
ECMAScript 5 every without scope |
|
pending… |
ECMAScript 5 every with scope |
|
pending… |
Best Combined without scope |
|
pending… |
Best Combined with scope |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Schleuse
- Revision 2: published
0 comments