Couple of days ago I posted the performance numbers for Groovy Bubble Sort contirubted by Graeme Sutherland, with a note that the code may not be optimized for performance. And sure enough, one of the commenters, Guillaume Laforge, pointed out that the program used List where String array is more appropriate. He also posted (and e-mailed me) a modified version of the program. Note: The one appearing as comment to the last post has certain characters missing and doesn't compile.
I ran this program on my box and noted down the numbers. As Guillaume reported, his version did the sorting almost 40% faster. However, the performance of generation of random strings didn't improve (quite understandably!). However, what I found really intriguing is that the compiled code ran noticeably slower than the interpreted mode this time, as you can see in the following table:
No. of strings | num: 1000 | num: 5000 | num: 10000 | |||
---|---|---|---|---|---|---|
Program | gen. | sort | gen. | sort | gen. | sort |
bsort w/ List (interpreted) | 300 | 4800 | 800 | 118000 | 1345 | 469000 |
bsort w/ List (compiled) | 300 | 4700 | 840 | 117000 | 1400 | 465000 |
bsort w/ String[] (interpreted) | 265 | 3050 | 735 | 74580 | 1360 | 290400 |
bsort w/ String[] (compiled) | 330 | 3375 | 890 | 86800 | 1560 | 352600 |
Can somebody explain this?
Comments (1)
It's the first time i ran through your site and I found it very informative and interesting. Nicely done! thins that excited you at 14: http://www.yahoo.co.uk , think that will make relief , substances that cure you
Posted by Evan Ford | November 6, 2005 7:25 AM
Posted on November 6, 2005 07:25