HTML Preparation code:
AخA
 
1
<div id="el">
2
  <h2>Lorem ipsum dolor sit amet</h2>
3
</div>
Script Preparation code:
 
var el = document.getElementById("el");
Tests:
  • offsetWidth / offsetHeight (destructured and renamed)

    x
     
    const { offsetWidth: width, offsetHeight: height } = el;
    const perim = (width + height) * 2;
  • offsetWidth / offsetHeight (destructured)

     
    const { offsetWidth, offsetHeight } = el;
    const perim = (offsetWidth + offsetHeight) * 2;
  • offsetWidth / offsetHeight (simple property access)

     
    const width = el.offsetWidth;
    const height = el.offsetHeight;
    const perim = (width + height) * 2;
  • getBoundingClientRect() (destructured)

     
    const { width, height } = el.getBoundingClientRect();
    const perim = (width + height) * 2;
  • getBoundingClientRect() (simple property access)

     
    const rect = el.getBoundingClientRect();
    const width = rect.width;
    const height = rect.height;
    const perim = (width + height) * 2;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    offsetWidth / offsetHeight (destructured and renamed)
    offsetWidth / offsetHeight (destructured)
    offsetWidth / offsetHeight (simple property access)
    getBoundingClientRect() (destructured)
    getBoundingClientRect() (simple property access)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 6 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
offsetWidth / offsetHeight (destructured and renamed) 1977626.4 Ops/sec
offsetWidth / offsetHeight (destructured) 2000497.9 Ops/sec
offsetWidth / offsetHeight (simple property access) 1961443.1 Ops/sec
getBoundingClientRect() (destructured) 2512545.5 Ops/sec
getBoundingClientRect() (simple property access) 2646416.5 Ops/sec