Do Canvas Dimensions need caching?

JavaScript performance comparison

Test case created by Andrew Cobby

Preparation code

<canvas width="4000" height="4000" id="testbed"></canvas>
      
<script>
Benchmark.prototype.setup = function() {
  var canvas = document.getElementById('testbed');
  var sizeCache = {
    width: canvas.width,
    height: canvas.height,
  };

};
</script>

Preparation code output

<canvas width="4000" height="4000" id="testbed"></canvas>

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.height|width
var height = canvas.height;
var width = canvas.width;
pending…
Js Object
var height = sizeCache.height;
var width = sizeCache.width;
pending…

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

0 Comments