[Haskell-cafe] newbie optimization question
Don Stewart
dons at galois.com
Sun Oct 28 15:01:14 EDT 2007
jerzy.karczmarczuk:
> Stefan O'Rear adds to the dialogue:
>
> >Prabhakar Ragde wrote:
> >>Jerzy Karczmarczuk wrote:
> >>
> >>>Just a trivial comment... 1. Don't speak about comparing *languages*
> >>>when you compare *algorithms*,
> >>> and in particular data structures.
> >>>2. Please, DO code the above in C, using linked lists. Compare then. 3.
> >>>Check the influence of bare printing, separated from the computation.
> >>
> >>Isn't GHC clever enough to optimize away the entire computation if there
> >>is no I/O?
> >
> >Yes, but GHC is not clever enough to solve the perfect number
> >classification problem. 'length' will suffice, and is prefered for most
> >enumeratioon benchmarks.
>
> My point didn't concern that point. Haskell compiler cannot change an
> algorithm using lists into something which deals with indexable arrays,
> usually faster. Indexing may be faster than the indirection, and the
> allocation of memory costs. And there is laziness...
> That's why I proposed to check what happens if one uses linked links in
> "C". Well, the follow-ups seem to suggest that the main time eater was the
> overloading. I must say that I am really astonished. It is hard to believe
> that such a signature can make a factor of 8. Never seen that before.
That fits with my experience writing low level numeric code -- Integer
can be a killer.
-- Don
More information about the Haskell-Cafe
mailing list