Recursive vs iterative object walk
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
function isObject (thing) {
return thing === Object(thing);
}
var data = {
'alpha': {
'chris': ['Truman', 'Toby'],
'josie': ['Darwin', 'Bruce', 'Sadie'],
'someone': {
'billy': ['programming', 'designing', 'rocking'],
'tom': {
'ian': {
'music': ['white stripes', 'black keys', 'britney spears'],
'hobbies': ['running', 'jumping', 'swimming']
}
}
}
},
'beta': {
'portland': ['pigs', 'chickens'],
'austin': {
'round rock': ['conservative', 'cowboys'],
'georgetown': ['stupid', 'annoying'],
'south austin': ['cool', 'trendy']
}
}
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Iterative |
|
pending… |
Recursive |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments