I guess the browser you're using is compiling the javascript more efficiently (probably by doing some kind of crazy optimization in the for loop) while PHP is not as good for optimizing for loops.
I guess the browser you're using is compiling the javascript more efficiently (probably by doing some kind of crazy optimization in the for loop) while PHP is not as good for optimizing for loops.
My question was: Why is the Javascript version 20 times faster on the same machine. I mean.. 20 is a really big factor.
Edit : Think about that : web browser are always on the cutting edge of javascript performance with the ton of javascript libraries that keep popping out each day. Everytime a new browser comes out, tons of bloggers test the javascript speed of those browsers so there is a lot of work going into optimizing javascript to make it as lightning-fast as possible.
On the other hand, PHP hasn't been pushed like that towards compile-time optimization so that's why Javascript can sometimes beat PHP in terms of speed tests.