HTML Preparation code:
AخA
 
1
<div id="element" style="background:#555;color:#FFF;position:absolute;left:0;top:0;width:400px;height:100px;">
2
</div>
Script Preparation code:
 
  var elem = document.getElementById('element');
function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));
}
Tests:
  • style by property

     
        elem.style.width = getRandomInt(500) + 'px';
        elem.style.height = '50px';
        elem.style.top = '40px';
        elem.style.left = '90px';
    i++;
  • style by name

     
        elem.style['width'] = getRandomInt(500) + 'px';
        elem.style['height'] = '50px';
        elem.style['top'] = '40px';
        elem.style['left'] = '90px';
  • setAttribute

     
    elem.setAttribute("style","width:" + getRandomInt(500) + "px;height:50px;top:40px;left:90px;");
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    style by property
    style by name
    setAttribute

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 6 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:65.0) Gecko/20100101 Firefox/65.0
Firefox 65 on Mac OS X 10.13
View result in a separate tab
Test name Executions per second
style by property 321774.6 Ops/sec
style by name 375698.9 Ops/sec
setAttribute 272987.7 Ops/sec