fillText And getImageData (v3)

Revision 3 of this benchmark created on


Description

Draw some text into a canvas and read it back.

Preparation HTML

<script>
  function makeContext(w, h) {
    var canvas = document.createElement('canvas');
    canvas.width = w;
    canvas.height = h;
    var ctx = canvas.getContext('2d');
    ctx.font = '12px arial,san-serif'
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    return ctx;
  }
  var ctx = makeContext(1024,1024);
  var ctx2 = makeContext(255, 64);
  
  function runTest(context) {
    context.fillText('a', 8, 8);
    context.fillText('b', 16, 8);
    context.fillText('c', 24, 8);
    var data = context.getImageData(0,0,24,16);
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
bigCanvas
runTest(ctx);
ready
smallCanvas
runTest(ctx2);
ready

Revisions

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