Canvas Pixel Manipulation
JavaScript performance comparison
Info
Tests two different methods of manipulating pixels using the canvas.
Preparation code
<canvas id="canvas" height="256" width="256"></canvas>
<script>
Benchmark.prototype.setup = function() {
var canvas = document.getElementById('canvas');
var canvasWidth = canvas.width;
var canvasHeight = canvas.height;
var ctx = canvas.getContext('2d');
var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
var data = imageData.data;
var buf = new ArrayBuffer(imageData.data.length);
var buf8 = new Uint8ClampedArray(buf);
var data32 = new Uint32Array(buf);
};
Benchmark.prototype.teardown = function() {
ctx.putImageData(imageData, 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… |
8-bit Typed 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
- Revision 75: published
0 comments