Re:Google Closure: How not to write Javascript
by asher on Thursday November 12, 2009 @02:16AM
(#937318)
I just tried it.
With 10M entries in the array, the "slow" way takes 509 ms and the "faster" way takes 362 ms. So we can save roughly 15 nanoseconds per iteration. Or a 30% speedup - assuming nothing happens inside the loop.
(Of course the numbers may vary wildly per browser.)
Somehow I doubt this is the performance problem behind slow web pages.
Re:Google Closure: How not to write Javascript
by brown9-2 on Thursday November 12, 2009 @07:23AM
(#937606)
Agreed - which makes pointing this out as the first problem in a "gee Google can't write JavaScript article" seems a bit overblown.
Re:Google Closure: How not to write Javascript
by manvsmachine on Thursday November 12, 2009 @01:20AM
(#937252)
In a case like this, it doesn't really matter how much of a performance benefit you get because it's ridiculously trivial to inmplement. This in particular is one of those optimizations that I remember being told back in CS101.
In other words, it's not very helpful to say "this is so slow, you should do this instead" without at least trying to quantify the difference somehow.