canvas-drawImage
JavaScript performance comparison
Preparation code
<script>
var c = document.createElement('canvas');
c.width = 256;
c.height = 256;
var ctx = c.getContext('2d');
ctx.fillRect(64, 64, 128, 128);
var img = new Image();
img.src = c.toDataURL();
var c2 = document.createElement('canvas');
c2.width = 512;
c2.height = 512;
var ctx2 = c2.getContext('2d');
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
aligned |
|
pending… |
offset |
|
pending… |
scaled |
|
pending… |
aligned img |
|
pending… |
offset img |
|
pending… |
scaled img |
|
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. Here’s a list of current revisions for this page:
- Revision 1: published by Ilmari
- Revision 2: published
- Revision 3: published by Ilmari Heikkinen
- Revision 6: published by Georg Petschnigg
1 comment
If the scaled scores are close to the unscaled scores, they should be pretty much as fast as unscaled when hoisting the ctx2.scale outside the loop. And you probably have a HW-accelerated canvas implementation in that case.