SetAttr

Benchmark created on


Preparation HTML

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <circle id="demo" cx="100" cy="50" r="40" stroke="black"
  stroke-width="2" />
</svg>

Setup

var demo = document.getElementById("demo");
    var value = "";

Test runner

Ready to run.

Testing in
TestOps/sec
Same Value
demo.setAttribute("fill", "red");
demo.setAttribute("fill", "red");
ready
Diff Value
demo.setAttribute("fill", "red");
demo.setAttribute("fill", "blue");
ready
Check Value Same
demo.setAttribute("fill", "red");
value = "red"
if(value != "red")
{
    demo.setAttribute("fill", "blue");
}
ready
Check Value Diff
demo.setAttribute("fill", "red");
value = "red";
if(value != "blue")
{
    demo.setAttribute("fill", "blue");
}
ready

Revisions

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