Replacing JavaScript Hot Path with WebAssembly
My guess is that the JS implementation of the worst-performing browser is having trouble with the non-1 for-loop steps. Doing 90-degree image rotation with fixed steps and some index calculations should work better (0.18 sec vs 1.5 sec for their implementation in node.js):<p><pre><code>    for (var y = 0; y &lt; height; y++)
        for (var x = 0; x &lt; width; x++)
            b[x + y*width] = a[y + (width - 1 - x)*height];
</code></pre>
Although that&#x27;s still far from the theoretical maximum throughput because the cache utilization is really bad. If you apply loop tiling, it should be even faster. This problem is closely related to matrix transpose, so there is a great deal of research you can build upon.<p>EDIT: 0.07 seconds with loop tiling:<p><pre><code>    for (var y0 = 0; y0 &lt; height; y0 += 64){
        for (var x0 = 0; x0 &lt; width; x0 += 64){
            for (var y = y0; y &lt; y0 + 64; y++){
                for (var x = x0; x &lt; x0 + 64; x++){
                    b[x + y*width] = a[y + (width - 1 - x)*height];</code></pre>