[Haskell-cafe] Re: newbie optimization question
simonmarhaskell at gmail.com
Mon Oct 29 09:08:16 EDT 2007
Peter Hercek wrote:
> Daniel Fischer wrote:
>> What perpetually puzzles me is that in C long long int has very good
>> performance, *much* faster than gmp, in Haskell, on my computer, Int64
>> is hardly faster than Integer.
> I tried the example with Int64 and Integer. The integer version
> was actually quicker ... which is the reason I decided to post
> the results.
> C++ version times: 1.125; 1.109; 1.125
> Int32 cpu times: 3.203; 3.172; 3.172
> Int64 cpu times: 11.734; 11.797; 11.844
> Integer cpu times: 9.609; 9.609; 9.500
> Interesting that Int64 is *slower* than Integer.
I can believe that. Integer is actually optimised for small values:
there's a specialised representation for values that fit in a single word
that avoids calling out to the GMP library.
As Stefan pointed out, there's a lot of room to improve the performance of
Int64, it's just never been a high priority.
More information about the Haskell-Cafe