Lennart Augustsson <[EMAIL PROTECTED]> wrote,

> So I did a test run too, on a 450MHz Pentuim II running NetBSD.
> I used Manuel's Haskell code, but I added a type signature for
> the expand function, and the original C++ code.
> 
> dogbert% cc c.cc -o c.out -lstdc++
> dogbert% time c.out
> 1942530768
> 1.043u 0.010s 0:01.05 100.0%    0+0k 0+1io 0pf+0w
> dogbert% hbc h3.hs
> dogbert% time a.out
> [1,9,4,2,5,3,0,7,6,8]
> 0.761u 0.040s 0:00.80 100.0%    0+0k 0+0io 0pf+0w
> dogbert%
> 
> So if you compile naively with no optimization the Haskell code
> is actually FASTER than the C++ code.

That's interesting.  Actually, I didn't add the type
signature, because when I tried using -O optimisation, it
didn't make a difference and I wanted to minimise the delta
to the original code.

>         no opt    opt
> hbc    0.761u    0.663u
> cc     1.055u    0.167u

Overall, I have (on a 300MHz Celeron running Linux and
including the type signature to expand),

                no opt   opt
  ghc  4.04pl1:  8.61u  2.63u
  egcs 1.1.2  :  1.70u  0.31u

So, either Lennart has a worse C++ compiler or a better
Haskell compiler - or, I got something completely wrong.
Without wanting to draw an early conclusion, wasn't there
this request in GHC's documentation to report any program
performing better when compiled with HBC as a bug :-)

Cheers,

Manuel

PS: Note that my machine is much slower machine than
    Lennart's, so an absolute comparison of our times is
    meaningless.


Reply via email to