habr_dom_access

Benchmark created on


Description

test dom acces by azproduction

Preparation HTML

<div id='pewpew'></div>
<script>
 var getter = function(a) {
  return document.getElementById(a);
 }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
normal model
document.getElementById('pewpew');
ready
closured
(function(window, document) {
 document.getElementById('pewpew');
}(this, this.document));
ready
normal x100
for (var i = 0, l = 500; l; --l, ++i) {
 document.getElementById('pewpew');
}
ready
clusure x10
(function(window, document) {
 for (var i = 0, l = 500; l; --l, ++i) {
  document.getElementById('pewpew');
 }
}(this, this.document));
ready
normal x100 g
for (var i = 0, l = 500; l; --l, ++i) {
 getter('pewpew');
}
ready
clusure x10 g
(function(window, document, getter) {
 for (var i = 0, l = 500; l; --l, ++i) {
  getter('pewpew');
 }
}(this, this.document, getter));
ready

Revisions

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