html vs svg vs canvas

JavaScript performance comparison

Revision 5 of this test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

      
<script>
Benchmark.prototype.setup = function() {
  var canvas = document.createElement('canvas');
  var svg = document.createElementNS("http:/ / www.w3.org / 2000 / svg ", 'svg');
  var container = document.createElement('div');
  var motherDiv = document.createElement('div');

};

Benchmark.prototype.teardown = function() {
  container.innerHTML = '';

};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
canvas
var paper = canvas.getContext('2d');
paper.fillRect(10, 10, 50, 50);
pending…
svg
var rect = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
rect.setAttribute("x", 10);
rect.setAttribute("y", 10);
rect.setAttribute("width", 50);
rect.setAttribute("height", 50);
svg.appendChild(rect);
pending…
div
var div = motherDiv.cloneNode();
div.style.position = "absolute";
div.style.top = "10px";
div.style.left = "10px";
div.style.width = "50px";
div.style.height = "50px";
container.appendChild(div);
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.

0 Comments