Typed array iteration
JavaScript performance comparison
Info
<canvas width="512" height="512" id="canvas" style="border: 1px dashed black;"></canvas>
Preparation code
<canvas width="512" height="512" id="canvas" style="border: 1px dashed black;"></canvas>
<script>
var classic = new Array(1310720);
var context = document.getElementById("canvas").getContext("2d");
var imageData = context.getImageData(0, 0, 512, 512);
var canvas = imageData.data;
if (typeof Uint8Array !== 'undefined') {
var typed8 = new Uint8Array(1310720);
var typed32 = new Uint32Array(1310720);
}
for (var i = 0; i < 1310720; ++i) {
var number = ~~ (Math.random() * 254)
classic[i] = number;
canvas[i] = number;
if (typeof Uint8Array !== 'undefined') {
typed8[i] = number;
typed32[i] = number;
}
}
context.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 | |
|---|---|---|
Classic |
|
pending… |
Canvas |
|
pending… |
Typed 8 |
|
pending… |
Typed 32 |
|
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 Bruno Garcia
- Revision 2: published by vjeux
- Revision 3: published by vjeux
- Revision 6: published by vjeux
- Revision 9: published by vjeux
- Revision 10: published by vjeux
- Revision 13: published by vjeux
- Revision 22: published
- Revision 23: published
- Revision 25: published
- Revision 26: published
- Revision 27: published
- Revision 28: published
- Revision 29: published
0 comments