computer language shootout

Thomas Hallgren
Mon, 30 Jul 2001 11:33:05 -0700

Josef Svenningsson wrote:

>On Mon, 30 Jul 2001, Simon Marlow wrote:
>>I've looked at a few.  The most common factor in the worst performers
>>seems to be the performance of String-related operations.  I tried
>>converting a few to use PackedStrings but that didn't help much.
>Well, I think the common factor is I/O. ...

Couldn't it sometimes also be really simple things, like how much time 
is spent in the garbage collector? As illustrated below, it first 
appears that HBC is faster than GHC (5.00.2) on a simple I/O & String 
manipulation benchmark, but, as the last test shows...

linux% cat interact.hs
main = interact (unlines . lines)
linux% hbc -O interact.hs
linux% time a.out < Input500 > Output500
7.870u 0.210s 0:08.08 100.0%    0+0k 0+0io 159pf+0w
linux% ghc -O2 interact.hs
linux% time a.out < Input500 > Output500
10.010u 0.190s 0:10.26 99.4%    0+0k 0+0io 150pf+0w
linux% time a.out +RTS -H2M < Input500 > Output500
6.220u 0.140s 0:06.35 100.1%    0+0k 0+0io 163pf+0w
linux% rpm -q ghc

The file Input500 is, 
repeated 500 times.

/Thomas Hallgren