cash vs dom

JavaScript performance comparison

Test case created

Preparation code

<div class="grid">
 <div>1</div>
 <div>1</div>
 <div>1</div>
 <div>1</div>
 <div>1</div>
</div>
<script>
Benchmark.prototype.setup = function() {
    var grid = document.querySelector('.grid'), x, y, tmp = grid.children;
};
</script>

Preparation code output

1
1
1
1
1

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
cashe
for (x = 0; x < 5; x ++) {
    tmp[x].firstChild.data = '8';
};
pending…
dom
for (x = 0; x < 5; x ++) {
    grid.children[x].firstChild.data = '9';
};
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment