Leaflet SVG vs Canvas

JavaScript performance comparison

Revision 9 of this test case created by

Preparation code

<script src="http://agafonkin.com/vector-test/zips.js"></script>

<script src="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js"></script>

<script>
Lsvg = L.noConflict();
L_PREFER_CANVAS = true;
</script>


<link rel="stylesheet" href="cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var div1 = document.createElement('div');
  div1.style.width = '600px';
  div1.style.height = '400px';
  document.body.appendChild(div1);
  
  var div2 = document.createElement('div');
  div2.style.width = '600px';
  div2.style.height = '400px';
  document.body.appendChild(div2);
  
  var map = L.map(div1).setView([42.066, -87.127], 8),
      mapSvg = Lsvg.map(div2).setView([42.066, -87.127], 8);
  
  L.Polyline.prototype.options.smoothFactor = 0;
  Lsvg.Polyline.prototype.options.smoothFactor = 0;
  
  var i = 0, len = 10;

};

Benchmark.prototype.teardown = function() {
  document.body.removeChild(div1);
  document.body.removeChild(div2);

};
</script>

Preparation code output

<script src="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js"></script> <script> Lsvg = L.noConflict(); L_PREFER_CANVAS = true; </script> <link rel="stylesheet" href="cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> <script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>

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

Revisions

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

0 Comments