childnodes caching (v2)

Revision 2 of this benchmark created by Karl Seamon on


Preparation HTML

<div id="cont"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>

Setup

var cont = document.getElementById('cont');
    var cache = {};
    cache.childNodes = cont.childNodes;
    
    var x, y;

Test runner

Ready to run.

Testing in
TestOps/sec
directly
x = cont.childNodes && cont.childNodes.length;
y = cont.childNodes;
ready
cached
var childNodes = cont.childNodes;
x = childNodes && childNodes.length;
y = childNodes;
ready

Revisions

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

  • Revision 2: published by Karl Seamon on