SVG-element-manipulation
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
Set Transform String |
|
pending… |
Manipulate transform with API |
|
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:
- Revision 1: published by Jens Podzierski
- Revision 2: published
- Revision 3: published
- Revision 4: published by Nathan Bingham
- Revision 5: published
- Revision 6: published
1 comment
Checks whether manipulating the svg by javascript api is faster than via DOM