SVG-element-manipulation

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script>
  var value = 42;
  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', 10);
  r1.setAttribute('width', 10);
  r1.setAttribute('y', 50);
  r1.setAttribute('x', 10);
  r1.setAttribute('stroke', '#000000');
  r1.setAttribute('fill', '#007fff');
  svg.appendChild(r1);

var r2 = r1;

  var transformbb = r2.ownerSVGElement.createSVGTransform();
  r2.transform.baseVal.appendItem(transformbb);


r1 = document.createElementNS(ns, 'rect');
  r1.setAttribute('height', 10);
  r1.setAttribute('width', 10);
  r1.setAttribute('y', 10);
  r1.setAttribute('x', 10);
  r1.setAttribute('stroke', '#000000');
  r1.setAttribute('fill', '#007fff');
  svg.appendChild(r1);
    var x = 0;
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Set Transform String
x = (x+5) % 123;
r2.transform.baseVal.getItem(0);
r1.setAttribute("transform", "translate(" + x + " 0)");
pending…
Manipulate transform with API
x = (x+5) % 123;
r2.transform.baseVal.getItem(0).matrix.e = x;
 
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment