SVG setAttribute/baseVal as number/string

Benchmark created by Alexis Deveria on


Preparation HTML

<script>
  var ns = "http://www.w3.org/2000/svg";
  var svg = document.createElementNS(ns, 'svg');
  document.body.appendChild(svg);
  var r1 = document.createElementNS(ns, 'rect');
  r1.setAttribute('height', 53);
  r1.setAttribute('width', 69);
  r1.setAttribute('y', 31);
  r1.setAttribute('x', 77);
  r1.setAttribute('stroke', '#000000');
  r1.setAttribute('fill', '#007fff');
  svg.appendChild(r1);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
setAttribute number
r1.setAttribute('width', 42);
ready
setAttribute string
r1.setAttribute('width', '42');
ready
set baseVal number
r1.width.baseVal.value = 42;
ready
set baseVal string
r1.width.baseVal.value = "42";
ready

Revisions

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

  • Revision 1: published by Alexis Deveria on
  • Revision 2: published by Alexis Deveria on
  • Revision 3: published by Alexis Deveria on
  • Revision 6: published on