HTML Preparation code:
AخA
 
1
<svg version="1.1"
2
     width="300" height="200"
3
     xmlns="http://www.w3.org/2000/svg">
4
  <rect id="rect1" width="100" height="100" fill="red" />
5
</svg>
Script Preparation code:
 
var rect = document.getElementById('rect1');
var width = Number(rect.getAttribute('width'));
Tests:
  • set the same value

     
    rect.setAttribute('width', width);
  • check and set nothing

     
    if (rect.getAttribute('width') !== `${width}`) {
      alert('this code does not run');
    }
  • check and set a new value

     
    if (rect.getAttribute('width') !== `${++width}`) {
      rect.setAttribute('width', width);
    }
  • set a new value

     
    rect.setAttribute('width', ++width);
  • check cache and set nothing

     
    const cache = width;
    if (cache !== width) {
      alert('this code does not run');
    }
  • check cache and set a new value

     
    const cache = width;
    if (cache !== ++width) {
      rect.setAttribute('width', width);
    }
  • check and set the same value

     
    if (rect.getAttribute('width') === `${width}`) {
      rect.setAttribute('width', width);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    set the same value
    check and set nothing
    check and set a new value
    set a new value
    check cache and set nothing
    check cache and set a new value
    check and set the same value

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 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
set the same value 11957576.0 Ops/sec
check and set nothing 51463064.0 Ops/sec
check and set a new value 1991300.0 Ops/sec
set a new value 4642188.0 Ops/sec
check cache and set nothing 167591792.0 Ops/sec
check cache and set a new value 4640350.0 Ops/sec
check and set the same value 7037838.0 Ops/sec