jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
This tests presumes that an initial fetch as been performed. The question is with respect to subsequent fetches.
Is there a big difference between redundant getElementById calls and caching the result
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<div id="one">
<div id="two">
<div id="three">
<div id="four">
this one
</div>
</div>
</div>
</div>
<script>
var get = _.memoize(_.bind(document.getElementById, document));
var obj = {
elems:{
el:document.getElementById("four")
}
};
var test1;
var test2;
var test3;
var test4;
var test5;
</script>
test1 = test2 = test3 = test4 = test5 = null;
Ready to run.
Test | Ops/sec | |
---|---|---|
5 getElementById calls |
| ready |
from cache |
| ready |
memoized |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.