[Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Peter Hercek
Derek Elkins wrote: Try with rem instead of mod. (What the heck is with bottom?) The bottom was there by error and I was lazy to redo the tests so I rather posted exactly what I was doing. I do not know the compiler that good to be absolutely sure it cannot have impact on result ... so I

[Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Peter Hercek
Don Stewart wrote: perfect :: [Int] perfect = [i | i-[1..1], i == sum (divisors i)] This should be a little faster , as sum will fuse, perfect :: [Int] perfect = [i | i-[1..1], i == sum' (divisors i)] where sum' = foldr (+) 0 sum' did not help. Times are about the

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Rodrigo Queiro
rem is faster because it has slightly different behaviour to mod, and there happens to be an intel instruction that maps more directly to rem than to mod, thus making it much faster on intel processors. Why do you expose perfect and divisors? Maybe if you just expose main, perfect and divisors

[Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Peter Hercek
Rodrigo Queiro wrote: Why do you expose perfect and divisors? Maybe if you just expose main, perfect and divisors will be inlined (although this will only save 10,000 function entries, so will probably have negligible effect). I exposed them so that I can check types in ghci. Hiding them does

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Dusan Kolar
Hello all, just to compare the stuff, I get quite other results being on other OS. Thus, the result of C++ compiler may not be that interesting as I do not have the one presented below. My machine: Linux 2.6.23-ARCH #1 SMP PREEMPT Mon Oct 22 12:50:26 CEST 2007 x86_64 Intel(R) Core(TM)2 CPU

[Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Simon Marlow
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

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Daniel Fischer
Am Montag, 29. Oktober 2007 13:49 schrieb Dusan Kolar: Hello all, just to compare the stuff, I get quite other results being on other OS. Thus, the result of C++ compiler may not be that interesting as I do not have the one presented below. Just to chime in, my results with the code below:

[Haskell-cafe] Re: newbie optimization question

2007-10-29 Thread Peter Hercek
OK, if somebody wants to speculate (and if it even makes sense for such a microbenchmark) here are some more data. Except different OS and C++ compiler also processor is different. On my side it was AMD Athlon 64 X2 4800+ (2.4GHz, 2x1MiB L2 cache non-shared; CQ was not switched off during the

[Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Peter Hercek
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

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Don Stewart
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

[Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Peter Hercek
Peter Hercek wrote: 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 Ooops, my results ware wrong (nonoptimizing ms cl compiler used and I used -O instead of -O2 in ghc). C++ version

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Don Stewart
peter: Peter Hercek wrote: 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 Ooops, my results ware wrong (nonoptimizing ms cl compiler used and I used -O instead of -O2 in ghc).

[Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Peter Hercek
Don Stewart wrote: C++ version times: 1.109; 1.125; 1.125 Int32 cpu times: 1.359; 1.359; 1.375 Int64 cpu times: 11.688; 11.719; 11.766 Integer cpu times: 9.719; 9.703; 9.703 Great result from ghc. What Haskell program were you using for this test? The original naive/high level implementation?

[Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Peter Hercek
Peter Hercek wrote: MS cl.exe version 13.10.3077 (options /G7 /MD) And I had cl options wrong too - I need to start to optimize not only to set the optimization target. /G7 /MD - 1.109; 1.125; 1.125 /Ox /G7 /MD - 0.922; 0.984; 0.984 Still it does not change the results too much.

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Derek Elkins
On Sun, 2007-10-28 at 23:34 +0100, Peter Hercek wrote: Don Stewart wrote: C++ version times: 1.109; 1.125; 1.125 Int32 cpu times: 1.359; 1.359; 1.375 Int64 cpu times: 11.688; 11.719; 11.766 Integer cpu times: 9.719; 9.703; 9.703 Great result from ghc. What Haskell program were

Re: [Haskell-cafe] Re: newbie optimization question

2007-10-28 Thread Don Stewart
peter: Don Stewart wrote: C++ version times: 1.109; 1.125; 1.125 Int32 cpu times: 1.359; 1.359; 1.375 Int64 cpu times: 11.688; 11.719; 11.766 Integer cpu times: 9.719; 9.703; 9.703 Great result from ghc. What Haskell program were you using for this test? The original naive/high level