i wg897awgfw7gf
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var each1 = function(obj, fn) {
var keys = Object.keys(obj), key;
while (key = keys.shift()) {
fn(key, obj[key]);
};
};
var each2 = function(obj, fn) {
var keys = Object.keys(obj);
var length = keys.length;
for (var i=0; i<length; i++) {
var key = keys[i];
fn(key, obj[key]);
};
};
var obj = {};
for (var i=0;i<10000;i++) {
obj[i] = 'asdf';
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
each1 |
|
pending… |
each2 |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments