drawImage whole pixels
JavaScript performance comparison
Preparation code
<canvas id="screen"></canvas>
<script>
var ctx = document.getElementById("screen").getContext("2d");
var image = document.createElement("img");
image.src = "http://icons.iconarchive.com/icons/ph03nyx/super-mario/48/Retro-Mushroom-1UP-2-icon.png";
function fasterRound(value)
{
return(~~(value+(value > 0 ? .5 : -.5)));
}
function fasterRoundPos(value)
{
return(~~(value+0.5));
}
function nop(value) { return(value); }
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
whole pixel |
|
pending… |
sub pixel |
|
pending… |
whole pixels 2 |
|
pending… |
integer pixel |
|
pending… |
whole pixels 3 |
|
pending… |
integer nop pixel |
|
pending… |
whole pixels 4 |
|
pending… |
sub nop pixel |
|
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
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published by skyblue
- Revision 12: published
- Revision 13: published
- Revision 14: published by ryan jacobson
- Revision 16: published
- Revision 17: published
0 comments