peter: > 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. > > On the other side the C version is not that much quicker. I guess > the Haskell version is using generic versions of mod and sum > (since they are from a library) which would mean indirect calls. > The Haskell version probably also creates the list nodes ... > even when they get almost immediately garbage collected. > > Thanks for pointing out Int64 sucks so much :)
With -O2 ghc will only have a function call to 'sum', with -O2 and the list stream fusion library, there are no indirect calls and the entire program is specialised to a nested loop. Do you have your C++ program handy? I'd expect the fully fused version to be somewhere between 1 and 2x slower. -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe