Canvas Pixel Manipulation
JavaScript performance comparison
Info
Tests two different methods of manipulating pixels using the canvas.
Preparation code
<canvas id="little" height="100" width="100">
</canvas>
<canvas id="big" height="200" width="200">
</canvas>
<script>
Benchmark.prototype.setup = function() {
var little = document.getElementById('little');
var littleCtx = little.getContext('2d');
var littleImg = littleCtx.getImageData(0, 0, little.width, little.height);
var littleData = littleImg.data;
var big = document.getElementById('big');
var bigCtx = big.getContext('2d');
var bigImg = bigCtx.getImageData(0, 0, big.width, big.height);
var bigData = bigImg.data;
var buf = new ArrayBuffer(bigImg.data.length);
var buf8 = new Uint8ClampedArray(buf);
var data32 = new Uint32Array(buf);
};
Benchmark.prototype.teardown = function() {
bigCtx.putImageData(bigImg, 0, 0);
littleCtx.putImageData(littleImg, 0, 0);
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
8-bit Pixel Manipulation |
|
pending… |
32-bit Pixel Manipulation |
|
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 Andrew J. Baker
- Revision 3: published
- Revision 4: published
- Revision 5: published by PlayMyCode
- Revision 6: published by Andrew J. Baker
- Revision 7: published
- Revision 8: published by PlayMyCode
- Revision 9: published by PlayMyCode
- Revision 10: published by PlayMyCode
- Revision 11: published
- Revision 18: published
- Revision 19: published by Arkanciscan
- Revision 23: published
- Revision 24: published
- Revision 27: published by imaya
- Revision 28: published
- Revision 29: published by ard
- Revision 30: published
- Revision 34: published
- Revision 35: published
- Revision 37: published by PAEz
- Revision 41: published
- Revision 42: published
- Revision 43: published
- Revision 44: published
- Revision 47: published by Autarc
- Revision 48: published
- Revision 49: published by Dan H
- Revision 50: published
- Revision 53: published by Russell Chapman
- Revision 54: published
- Revision 56: published by HotSix
- Revision 57: published by Andymensional
- Revision 62: published
- Revision 63: published
- Revision 64: published
- Revision 65: published
- Revision 66: published
- Revision 67: published
- Revision 68: published
- Revision 69: published
- Revision 72: published by orwellophile
0 comments