Forget it, my bad.

On 20 Feb 2009, at 16:48, Miguel Mitrofanov wrote:

Ahem. Seems like you've included time spent on the runtime loading.

My results:

MigMit:~ MigMit$ gcc -o test -O3 -funroll-loops test.c && time ./test
-1243309312
real    0m0.066s
user    0m0.063s
sys     0m0.002s
MigMit:~ MigMit$ rm test; ghc -O2 --make test.hs && time ./test
Linking test ...
-243309312

real    0m3.201s
user    0m3.165s
sys     0m0.017s

While 3.201 vs. 0.066 seem to be a huge difference, 0.017 vs. 0.002 is not that bad.

On 20 Feb 2009, at 16:29, Bulat Ziganshin wrote:

Hello haskell-cafe,

since there are no objective tests comparing ghc to gcc, i made my own
one. these are 3 programs, calculating sum in c++ and haskell:

main = print $ sum[1..10^9::Int]


main = print $ sum0 (10^9) 0

sum0 :: Int -> Int -> Int
sum0 0  !acc = acc
sum0 !x !acc = sum0 (x-1) (acc+x)


main()
{
int sum=0;
//for(int j=0; j<100;j++)
  for(int i=0; i<1000*1000*1000;i++)
    sum += i;
return sum;
}

execution times:
sum:
 ghc 6.6.1 -O2               : 12.433 secs
 ghc 6.10.1 -O2              : 12.792 secs
sum-fast:
 ghc 6.6.1 -O2               :  1.919 secs
 ghc 6.10.1 -O2              :  1.856 secs
 ghc 6.10.1 -O2 -fvia-C      :  1.966 secs
C++:
 gcc 3.4.5 -O3 -funroll-loops:  0.062 secs


--
Best regards,
Bulat                          mailto:bulat.zigans...@gmail.com

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to