[GHC] #6000: Performance of Fibonnaci compare to Python
GHC
cvs-ghc at haskell.org
Thu Apr 12 04:06:07 CEST 2012
#6000: Performance of Fibonnaci compare to Python
-------------------------------------+--------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.4.1 | Keywords: python, performance
Os: Linux | Architecture: x86_64 (amd64)
Failure: Runtime performance bug | Testcase:
Blockedby: | Blocking:
Related: |
-------------------------------------+--------------------------------------
There's a 4 second, unjustified, difference in performance between the
following Python fibonacci implementation and it's equivalent Haskell
implementation (though the output core seems to be just fine!).
-----PYTHON------
def fib(n):
one = 0
two = 1
for i in range(0,n):
temp = two
two = one + two
one = temp
return one
if __name__ == "__main__":
print fib(1000000);
----HASKELL-------
{-# LANGUAGE BangPatterns #-}
fib :: Int -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib' 0 1 2 where
fib' _ y n' | n' > n = y
fib' !x !y !n' = fib' y (x+y) (n'+1)
main = fib 1000000 `seq` return ()
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6000>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list