Not all browsers are made equal in speedApril 3, 2006
Today I had an enlightening experience. As I complained a couple of days ago, @Sweeper 0.8 (my Morfik Mine Sweeper clone) was dead slow when switching into Intermediate or Expert mode due to a lot of control demolitions/creations going on in the background. So I decided that some optimization was in order and today just wanted to look into doing this when (almost by coincidence) I discovered that the speed was much-much better (almost palatable for even a maximalist) than I originally experienced. What gives?
When I develop with Morfik, it uses Internet Explorer (6.0 XP/SP2) by default to run the application. I discovered the performance problems this way while running the app from the IDE.
Today I started the app from the command line (I wanted to take a look at the generated code) and it came up in Firefox (1.5) since that is the default browser on the same machine. Was I surprised seeing that it was noticeably faster to switch modes!
My first reaction was to think of a few ‘nice’ words about my ignorance in forgetting how an IDE can affect performance by doing some extra hops for debugging in the background (in retrospect: is this so in Morfik’s case? I’ll figure that out…).
Then I remembered that indeed I had done some profiling the other day and narrowed down the possible number of lines for the performance issue quite a lot and none of those lines should be affected by IDE magick.
So decided to do some investigations and did profile the same task (switching from Basic into Expert) in both browsers on the same machine with the same conditions (only the two browsers loaded, average of 5 runs for each). Here are the results:
- Internet Explorer finished on average in 18.34 secs
- Firefox finished on average in 3.38 secs
Now, that IS a difference. In this test Firefox was faster by cca. 5.42 times.
One could say that this is irrelevant and why do I care in the first place? The answer is simple. New web applications (based on AJAX) and many Web 2.0 frameworks (Morfik, Backbase, the new OpenLaszlo DHTML renderer, Ruby on Rails, etc.) rely on the browser as a UI rendering engine. Such great differences in speed mean that either the browser manufacturers will have to tune their solutions to be more in line or we application developers will have again to do some magic to mitigate the differences (of course, this is not optimized code, but that is not the point, OK?).
If you want to take a look at the results first hand, you can do it by either running the Mine Sweeper app from the Morfik Dev2Dev site or downloading the source code and running it locally (it is pre-compiled in the archive).