
Hello, During a talk with a friend I came up with two programs, one written in C and another in haskell. Haskell main :: IO () main = print $ rangeI 0 0 rangeK :: Int -> Int -> Int -> Int -> Int rangeK i j k acc | k < 1000 = if i * i + j * j + k * k `mod` 7 == 0 then rangeK i j (k+1) (acc+1) else rangeK i j (k+1) acc | otherwise = acc rangeJ :: Int -> Int -> Int -> Int rangeJ i j acc | j < 1000 = rangeJ i (j+1) (acc + rangeK i j 0 0) | otherwise = acc rangeI :: Int -> Int -> Int rangeI i acc | i < 1000 = rangeI (i+1) (acc + (rangeJ i 0 0)) | otherwise = acc C main() { printf("%d\n", rangeI(0, 0)); return 0; } rangeK(i, j, k, acc) { if (k < 1000) { if (i * i + j * j + k * k % 7 == 0) return rangeK(i, j, k+1, acc+1); else return rangeK(i, j, k+1, acc); } else return acc; } rangeJ(i, j, acc) { if (j < 1000) return rangeJ(i, j+1, acc + rangeK(i, j, 0, 0)); else return acc; } rangeI(i, acc) { if (i < 1000) return rangeI(i+1, acc + rangeJ(i, 0, 0)); else return acc; } I tried to keep both programs as similar as possible. I'm pretty confident that the algorithm being executed are exactly the same. That is, there's no lists being used vs. arrays or anything like that. I even used Int instead of Integer to make sure an equivalent version of +, * and mod are called (perhaps that was what I did wrong?) I compiled the haskell code with ghc -O3 and I compiled the C code with gcc -O3. The execution time of the programs were dramatically different. You can test it yourselves, but here is the time I've got in my system: The Haskell version: real 0m45.335s user 0m45.275s sys 0m0.004s against the C version: real 0m6.021s user 0m6.004s sys 0m0.004s Also, I found it interesting that a iterative version of that algorithm in C ran in the same time as the recursive version. So it seems like gcc was successfuly able to make those tail recursive functions into iterations. It strikes me as surprising that Haskell would perform so much slower in that example. I was expecting maybe a few seconds due to the garbage collector or something like that, but not more than 7 times slower.

On Fri, Mar 26, 2010 at 10:46 AM, Rafael Cunha de Almeida < almeidaraf@gmail.com> wrote:
Hello,
During a talk with a friend I came up with two programs, one written in C and another in haskell.
Haskell main :: IO () main = print $ rangeI 0 0
rangeK :: Int -> Int -> Int -> Int -> Int rangeK i j k acc | k < 1000 = if i * i + j * j + k * k `mod` 7 == 0 then rangeK i j (k+1) (acc+1) else rangeK i j (k+1) acc | otherwise = acc
rangeJ :: Int -> Int -> Int -> Int rangeJ i j acc | j < 1000 = rangeJ i (j+1) (acc + rangeK i j 0 0) | otherwise = acc
rangeI :: Int -> Int -> Int rangeI i acc | i < 1000 = rangeI (i+1) (acc + (rangeJ i 0 0)) | otherwise = acc
You might try using bang patterns. It's possible that GHC didn't detect the strictness. Only way I know to check is to look at the core. Use something like ghc-core from Hackage to view it. Ideally the core is using Int# instead of Int and avoiding lots of boxing.
I compiled the haskell code with ghc -O3 and I compiled the C code with gcc -O3. The execution time of the programs were dramatically different. You can test it yourselves, but here is the time I've got in my system:
You might try -Odph . See http://book.realworldhaskell.org/read/profiling-and-optimization.htmlfor more ideas. Jason

Here are jhc's timings for the same programs on my machine. gcc and ghc both used -O3 and jhc had its full standard optimizations turned on. jhc: ./hs.out 5.12s user 0.07s system 96% cpu 5.380 total gcc: ./a.out 5.58s user 0.00s system 97% cpu 5.710 total ghc: ./try 31.11s user 0.00s system 96% cpu 32.200 total As you can see, jhc shines at this example, actually beating gcc -O3. It isn't too surprising, this is exactly the sort of haskell code that jhc excels at. John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/

Hi John,
Any chance of seeing the benchmark? You're not the only one with an
optimising compiler tucked away somewhere :-)
I have one "benchmark" where I outperform GHC by 21 times, although
saying it's artificial is a bit of an understatement...
Thanks, Neil
On Fri, Mar 26, 2010 at 6:27 PM, John Meacham
Here are jhc's timings for the same programs on my machine. gcc and ghc both used -O3 and jhc had its full standard optimizations turned on.
jhc: ./hs.out 5.12s user 0.07s system 96% cpu 5.380 total
gcc: ./a.out 5.58s user 0.00s system 97% cpu 5.710 total
ghc: ./try 31.11s user 0.00s system 96% cpu 32.200 total
As you can see, jhc shines at this example, actually beating gcc -O3. It isn't too surprising, this is exactly the sort of haskell code that jhc excels at.
John
-- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Sat, Mar 27, 2010 at 3:25 AM, Neil Mitchell
Hi John,
Any chance of seeing the benchmark? You're not the only one with an optimising compiler tucked away somewhere :-)
Neil, for some reason John's reply didn't thread with the rest of the thread. Probably because he changed the subject. He was referring to this thread: http://www.haskell.org/pipermail/haskell-cafe/2010-March/075151.html Jason

John Meacham wrote:
Here are jhc's timings for the same programs on my machine. gcc and ghc both used -O3 and jhc had its full standard optimizations turned on.
jhc: ./hs.out 5.12s user 0.07s system 96% cpu 5.380 total
gcc: ./a.out 5.58s user 0.00s system 97% cpu 5.710 total
ghc: ./try 31.11s user 0.00s system 96% cpu 32.200 total
As you can see, jhc shines at this example, actually beating gcc -O3. It isn't too surprising, this is exactly the sort of haskell code that jhc excels at.
What's the property of that code which makes jhc excels in it? What makes ghc perform so poorly in comparison?

It's important to switch from mod to rem. This can be done by a
simple abstract interpretation.
I'm nore sure if it's jhc or gcc that does this for jhc.
-- Lennart
On Sat, Mar 27, 2010 at 10:30 PM, Rafael Cunha de Almeida
John Meacham wrote:
Here are jhc's timings for the same programs on my machine. gcc and ghc both used -O3 and jhc had its full standard optimizations turned on.
jhc: ./hs.out 5.12s user 0.07s system 96% cpu 5.380 total
gcc: ./a.out 5.58s user 0.00s system 97% cpu 5.710 total
ghc: ./try 31.11s user 0.00s system 96% cpu 32.200 total
As you can see, jhc shines at this example, actually beating gcc -O3. It isn't too surprising, this is exactly the sort of haskell code that jhc excels at.
What's the property of that code which makes jhc excels in it? What makes ghc perform so poorly in comparison? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Lennart Augustsson wrote:
It's important to switch from mod to rem. This can be done by a simple abstract interpretation. I'm nore sure if it's jhc or gcc that does this for jhc.
It's not just adding rem. Ghc still runs much slower using rem. It's only when switching to -fvia-C and using rem that ghc gets close to gcc speed (even though, still slower). Now jhc seems to get it fast right away. What's going on here? Is ghc backend wrose than using gcc as a backend (which is what via-C seems to accomplish)? Are there cases when one way is preferred over the other? What are the tradeoffs here?

On 28/03/2010, at 09:47, Lennart Augustsson wrote:
It's important to switch from mod to rem. This can be done by a simple abstract interpretation.
Also, changing the definition of rem from a `rem` b | b == 0 = divZeroError | a == minBound && b == (-1) = overflowError | otherwise = a `remInt` b to a `rem` b | b == 0 = divZeroError | b == (-1) && a == minBound = overflowError | otherwise = a `remInt` b speeds up the GHC version by about 20%. Figuring out why is left as an exercise to the reader :-) Roman

Does anything change if you swap the first two rhss?
On Sun, Mar 28, 2010 at 1:28 AM, Roman Leshchinskiy
On 28/03/2010, at 09:47, Lennart Augustsson wrote:
It's important to switch from mod to rem. This can be done by a simple abstract interpretation.
Also, changing the definition of rem from
a `rem` b | b == 0 = divZeroError | a == minBound && b == (-1) = overflowError | otherwise = a `remInt` b
to
a `rem` b | b == 0 = divZeroError | b == (-1) && a == minBound = overflowError | otherwise = a `remInt` b
speeds up the GHC version by about 20%. Figuring out why is left as an exercise to the reader :-)
Roman
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 29/03/2010, at 02:27, Lennart Augustsson wrote:
Does anything change if you swap the first two rhss?
No, not as far as I can tell.
On Sun, Mar 28, 2010 at 1:28 AM, Roman Leshchinskiy
wrote: On 28/03/2010, at 09:47, Lennart Augustsson wrote:
It's important to switch from mod to rem. This can be done by a simple abstract interpretation.
Also, changing the definition of rem from
a `rem` b | b == 0 = divZeroError | a == minBound && b == (-1) = overflowError | otherwise = a `remInt` b
to
a `rem` b | b == 0 = divZeroError | b == (-1) && a == minBound = overflowError | otherwise = a `remInt` b
speeds up the GHC version by about 20%. Figuring out why is left as an exercise to the reader :-)
Roman
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Sat, Mar 27, 2010 at 07:30:30PM -0300, Rafael Cunha de Almeida wrote:
John Meacham wrote:
Here are jhc's timings for the same programs on my machine. gcc and ghc both used -O3 and jhc had its full standard optimizations turned on.
jhc: ./hs.out 5.12s user 0.07s system 96% cpu 5.380 total
gcc: ./a.out 5.58s user 0.00s system 97% cpu 5.710 total
ghc: ./try 31.11s user 0.00s system 96% cpu 32.200 total
As you can see, jhc shines at this example, actually beating gcc -O3. It isn't too surprising, this is exactly the sort of haskell code that jhc excels at.
I have not thoroughly checked it, but I think there are a couple things going on here: jhc is able to determine that all the arguments to the various functions are strict, so it can avoid all heap allocations and evaluations. ghc also benefits from this optimization. jhc sees that all the functions are fully applied to all their arguments, this means that they can always be directly called with optimized calling conventions as they will never have to represent generic 'eval' thunks or partial applications. it sees that all the functions are local to 'main' and not exported, so it can actually translate them to local functions in main in grin, allowing some more useful optimizations. Now the most important one, after optimizing the local functions, jhc sees that they are only called in tail-call position, so jhc is able to turn the function calls into direct jumps, turning them directly into C while/for loops operating fully on automatic variables on the stack. These last two optimizations are enabled by an incredibly useful extension to boquist's GRIN which is to allow a form of local function definitions, which solve a number of issues raised in his paper. Via a series of Grin->Grin transformations I am able to turn these local funciton definitions into direct conditional jumps in the resulting code. (which translate to looping constructs, if's and goto's in C) John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/

On 28/03/2010, at 11:07, John Meacham wrote:
I have not thoroughly checked it, but I think there are a couple things going on here:
It could also be worthwhile to float out (i*i + j*j) in rangeK instead of computing it in every loop iteration. Neither ghc nor gcc can do this; if jhc can then that might explain the performance difference (although I would expect it to be larger in this case). Roman

On 27/03/2010, at 05:27, John Meacham wrote:
Here are jhc's timings for the same programs on my machine. gcc and ghc both used -O3 and jhc had its full standard optimizations turned on.
jhc: ./hs.out 5.12s user 0.07s system 96% cpu 5.380 total
gcc: ./a.out 5.58s user 0.00s system 97% cpu 5.710 total
ghc: ./try 31.11s user 0.00s system 96% cpu 32.200 total
I really don't understand these GHC numbers. I get about 3s for the C version, about 5s for GHC with rem and about 7.5s for GHC with mod. Is this perhaps on a 64-bit system? What is sizeof(int) in C and sizeOf (undefined :: Int) in Haskell? That said, I suspect the only thing this benchmark really measures is how fast the various compilers can compute i * i + j * j + k * k `mod` 7. Roman

On Fri, Mar 26, 2010 at 10:46 AM, Rafael Cunha de Almeida < almeidaraf@gmail.com> wrote:
During a talk with a friend I came up with two programs, one written in C and another in haskell.
Your Haskell code builds a huge thunked accumulator value, so of course it's slow (put bang patterns on all arguments). Also, you should use rem instead of mod. Make those tiny changes and you'll get a 5x speedup, to half the performance of the C code.

On Fri, Mar 26, 2010 at 2:33 PM, Bryan O'Sullivan
On Fri, Mar 26, 2010 at 10:46 AM, Rafael Cunha de Almeida < almeidaraf@gmail.com> wrote:
During a talk with a friend I came up with two programs, one written in C and another in haskell.
Your Haskell code builds a huge thunked accumulator value, so of course it's slow (put bang patterns on all arguments). Also, you should use rem instead of mod. Make those tiny changes and you'll get a 5x speedup, to half the performance of the C code.
Interesting. I had to add -fvia-C to get within half the performance of C. Just bang patterns and rem and I'm 1/5th of C. I'm on a x86_64 machine. I wonder if that plays in. Jason

I'd guess that the LLVM backend could generate code that is at least as fast as gcc. It would be nice if you could test it. -- Felipe.

On Fri, Mar 26, 2010 at 6:16 PM, Felipe Lessa
I'd guess that the LLVM backend could generate code that is at least as fast as gcc. It would be nice if you could test it.
NCG done with GHC 6.12.1 w/ -O3 LLVM using a version of HEAD w/ -O3 GCC version 4.4.3 w/ -O3 Please take note Johns benchmark of JHC showing it beats everything here (including C). Also note -Odph did not alter performance from -O3. [tommd@Mavlo Test]$ time ./blahC 143 real 0m4.124s user 0m4.032s sys 0m0.013s [tommd@Mavlo Test]$ time ./blahLLVM 143 real 0m5.045s user 0m4.984s sys 0m0.006s [tommd@Mavlo Test]$ time ./blahNCG 143 real 0m5.960s user 0m5.872s sys 0m0.008s Cheers, Thomas

On Fri, Mar 26, 2010 at 6:49 PM, Jason Dagit
On Fri, Mar 26, 2010 at 2:33 PM, Bryan O'Sullivan
wrote: On Fri, Mar 26, 2010 at 10:46 AM, Rafael Cunha de Almeida
wrote: During a talk with a friend I came up with two programs, one written in C and another in haskell.
Your Haskell code builds a huge thunked accumulator value, so of course it's slow (put bang patterns on all arguments). Also, you should use rem instead of mod. Make those tiny changes and you'll get a 5x speedup, to half the performance of the C code.
Interesting. I had to add -fvia-C to get within half the performance of C. Just bang patterns and rem and I'm 1/5th of C. I'm on a x86_64 machine. I wonder if that plays in.
Jason
Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s. What's going on here? Doesn't ghc do tail recursion optimization?

Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s.
Bang patterns should have helped tons - it isn't GHC thats at fault here and yes it does tco. I attached a version w/ excessive bangs below. Did you compile with "ghc --make -O3 -fforce-recomp"? Cheers, Thomas main = print $ rangeI 0 0 rangeK :: Int -> Int -> Int -> Int -> Int rangeK !i !j !k !acc = if k < 1000 then if i * i + j * j + k * k `rem` 7 == 0 then rangeK i j (k+1) (acc+1) else rangeK i j (k+1) acc else acc rangeJ :: Int -> Int -> Int -> Int rangeJ !i !j !acc = if j < 1000 then rangeJ i (j+1) (acc + rangeK i j 0 0) else acc rangeI :: Int -> Int -> Int rangeI !i !acc = if i < 1000 then rangeI (i+1) (acc + (rangeJ i 0 0)) else acc

On Sat, Mar 27, 2010 at 12:56 AM, Thomas DuBuisson
Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s.
Bang patterns should have helped tons - it isn't GHC thats at fault here and yes it does tco. I attached a version w/ excessive bangs below. Did you compile with "ghc --make -O3 -fforce-recomp"?
Does -O3 actually do anything? GHC only goes up to -O2.
--
Dave Menendez

David Menendez wrote:
On Sat, Mar 27, 2010 at 12:56 AM, Thomas DuBuisson
wrote: Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s. Bang patterns should have helped tons - it isn't GHC thats at fault here and yes it does tco. I attached a version w/ excessive bangs below. Did you compile with "ghc --make -O3 -fforce-recomp"?
Does -O3 actually do anything? GHC only goes up to -O2.
Well GHC has an -O3[1], but it's not a good idea to use it. Some of the "optimizations" that -O3 does can result in slower code for particular programs. Whereas -O2 is safe and never results in pessimizations. [1] Unless recent versions have removed it. -- Live well, ~wren

On 10-03-26 11:50 PM, wren ng thornton wrote:
Well GHC has an -O3[1], but it's not a good idea to use it. Some of the "optimizations" that -O3 does can result in slower code for particular programs. Whereas -O2 is safe and never results in pessimizations.
Slightly off topic, but ACOVEA may be an interesting item to see here. http://www.coyotegulch.com/products/acovea/ Pom.

On Fri, 26 Mar 2010 21:56:16 -0700, Thomas DuBuisson wrote:
Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s.
Bang patterns should have helped tons - it isn't GHC thats at fault here and yes it does tco. I attached a version w/ excessive bangs below. Did you compile with "ghc --make -O3 -fforce-recomp"?
I can verify that it is not bang patterns that helped, it is an issue related to `mod' vs. `rem'. mod w/o bang: 30.73s user 0.15s system 99% cpu 30.954 total rem w/o bang: 6.52s user 0.00s system 99% cpu 6.528 total mod w/ bang: 30.53s user 0.25s system 99% cpu 30.878 total rem w/ bang: 6.34s user 0.00s system 99% cpu 6.359 total Compiled with: ghc --make -fexcess-precision -funbox-strict-fields -O3 -Wall -optc-O3 -optc-march=native -optl-Wl,-s -fvia-c -fforce-recomp test.hs -o test-hs And for comparison, c version: 4.35s user 0.04s system 99% cpu 4.403 total Linux 2.6.33-ARCH #1 SMP PREEMPT Mon Mar 15 19:11:52 CET 2010 x86_64 GenuineIntel GNU/Linux Best, jxy -- J c/* __o/* X <\ * (__ Y */\ <

Hi, Rafael Almeida wrote:
On Fri, Mar 26, 2010 at 6:49 PM, Jason Dagit
wrote: Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s. What's going on here? Doesn't ghc do tail recursion optimization?
I see similar surprising results here on x86_64 Linux, GHC 6.10.4 (version with bangs): -fasm real 0m25.239s user 0m25.218s sys 0m0.012s -via-c real 0m8.699s user 0m8.641s sys 0m0.020s Best, -- Grzegorz -- View this message in context: http://old.nabble.com/GHC-vs-GCC-tp28045806p28050734.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Sat, Mar 27, 2010 at 12:43 AM, Rafael Almeida
On Fri, Mar 26, 2010 at 6:49 PM, Jason Dagit
wrote: On Fri, Mar 26, 2010 at 2:33 PM, Bryan O'Sullivan
wrote: On Fri, Mar 26, 2010 at 10:46 AM, Rafael Cunha de Almeida
wrote: During a talk with a friend I came up with two programs, one written in C and another in haskell.
Your Haskell code builds a huge thunked accumulator value, so of course it's slow (put bang patterns on all arguments). Also, you should use rem instead of mod. Make those tiny changes and you'll get a 5x speedup, to
half
the performance of the C code.
Interesting. I had to add -fvia-C to get within half the performance of C. Just bang patterns and rem and I'm 1/5th of C. I'm on a x86_64 machine. I wonder if that plays in.
Jason
Using bang patterns didn't help almost anything here. Using rem instead of mod made the time go from 45s to 40s. Now, using -fvia-C really helped (when I used rem but not using mod). It went down to 10s.
It's worth pointing out that there's a bit of bang-pattern mysticism going on in this conversation (which has not been uncommon of late!). A non-buggy strictness analyzer should expose the strictness of these functions without difficulty. If bang patterns make any difference at all with a -O flag, either there's a strictness analysis bug, or some very interesting effects from shifting the order of forcing of strict variables. Putting in bang patterns is a good idea to plug the obvious space leak when run without optimization, but isn't going to make a difference for optimizing compilation of obviously-strict functions. -Jan-Willem Maessen

Jan-Willem Maessen wrote:
It's worth pointing out that there's a bit of bang-pattern mysticism going on in this conversation (which has not been uncommon of late!). A non-buggy strictness analyzer should expose the strictness of these functions without difficulty.
Could the result of strictness analysis reported in terms of the original Haskell program?
ghc -O2 -ddump-strictness test.hs
test.hs:3:1: Top-level function `foo' is found to be strict in the first and third argument. This could help people gain confidence in the strictness analyzer. Tillmann

On Sat, Mar 27, 2010 at 1:45 PM, Tillmann Rendel
Jan-Willem Maessen wrote:
It's worth pointing out that there's a bit of bang-pattern mysticism going on in this conversation (which has not been uncommon of late!). A non-buggy strictness analyzer should expose the strictness of these functions without difficulty.
Could the result of strictness analysis reported in terms of the original Haskell program?
That would be nice. Even if you're willing to read core, I'm not aware
that the output of -ddump-stranal is explained anywhere.
Incidentally, the results of -ddump-simpl when running on -O2 say that
GHC has unboxed every argument except the first argument to rangeJ.
--
Dave Menendez

On 28/03/2010, at 01:36, Jan-Willem Maessen wrote:
It's worth pointing out that there's a bit of bang-pattern mysticism going on in this conversation (which has not been uncommon of late!). A non-buggy strictness analyzer should expose the strictness of these functions without difficulty.
Actually, rangeJ is lazy in i and rangeK is lazy in i and j. GHC does unbox everything important here but that needs more optimisations than just strictness analysis. You are right, though, that GHC doesn't need bang patterns here. Roman

On Sat, Mar 27, 2010 at 8:16 PM, Roman Leshchinskiy
On 28/03/2010, at 01:36, Jan-Willem Maessen wrote:
It's worth pointing out that there's a bit of bang-pattern mysticism going on in this conversation (which has not been uncommon of late!). A non-buggy strictness analyzer should expose the strictness of these functions without difficulty.
Actually, rangeJ is lazy in i and rangeK is lazy in i and j. GHC does unbox everything important here but that needs more optimisations than just strictness analysis. You are right, though, that GHC doesn't need bang patterns here.
Quite right, the condition in rangeK that mentions all variables is under another condition: rangeK :: Int -> Int -> Int -> Int -> Int rangeK i j k acc | k < 1000 = if i * i + j * j + k * k `mod` 7 == 0 ... So we need to apply some constructor specialization as well to notice that i and j are always of the form (Int# i#). -Jan Roman

On 27 March 2010 04:46, Rafael Cunha de Almeida
During a talk with a friend I came up with two programs, one written in C and another in haskell.
snip
The Haskell version: real 0m45.335s user 0m45.275s sys 0m0.004s
against the C version: real 0m6.021s user 0m6.004s sys 0m0.004s
Could you please report which version of each compiler, which operating system, and which CPU? Cheers, Bernie.

On Fri, Mar 26, 2010 at 10:42 PM, Bernie Pope
On 27 March 2010 04:46, Rafael Cunha de Almeida
wrote: During a talk with a friend I came up with two programs, one written in C and another in haskell.
snip
The Haskell version: real 0m45.335s user 0m45.275s sys 0m0.004s
against the C version: real 0m6.021s user 0m6.004s sys 0m0.004s
Could you please report which version of each compiler, which operating system, and which CPU?
My operating system is a Debian Lenny GNU/Linux, my CPU is: $ grep 'model name' /proc/cpuinfo model name : Intel(R) Core(TM)2 Duo CPU T5550 @ 1.83GHz I'm using ghc 6.8.2 and gcc 4.3.2, both from lenny package. I tried the same code with ghc 6.12.1 and the result was the same: real 0m45.121s user 0m45.075s sys 0m0.000s
participants (18)
-
Bernie Pope
-
Bryan O'Sullivan
-
David Menendez
-
Felipe Lessa
-
Grzegorz C
-
Jan-Willem Maessen
-
Jason Dagit
-
John Meacham
-
Lennart Augustsson
-
Neil Mitchell
-
Pom
-
Rafael Almeida
-
Rafael Cunha de Almeida
-
Roman Leshchinskiy
-
Thomas DuBuisson
-
Tillmann Rendel
-
wren ng thornton
-
Xiao-Yong Jin