HTML Preparation code:
AخA
 
1
<div id="testdiv">
2
  <div id="unique1" class="unique" name="unique" data-unique="1">test1</div>
3
  <div id="unique2" class="unique1" name="unique" data-unique="2">test2</div>
4
  <div id="unique3" class="unique" name="unique" data-unique="3">test3</div>
5
  <div id="unique4" class="unique" name="unique" data-unique="4">test4</div>
6
  <div id="unique5" class="unique" name="unique" data-unique="5">test5</div>
7
</div>
Script Preparation code:
 
var i, imax;
var doc = document;
Tests:
  • getElementById

     
    var test = doc.getElementById('testdiv').childNodes[0].innerHTML;
  • getElementById and getElementsByClassName

     
    var test = doc.getElementsByClassName('unique1')[0].innerHTML;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    getElementById
    getElementById and getElementsByClassName

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 29 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Firefox 136 on Windows
View result in a separate tab
Test name Executions per second
getElementById 28853520.0 Ops/sec
getElementById and getElementsByClassName 21813820.0 Ops/sec