OUT-OF-DATE! Read http://shootout.alioth.debian.org/ |
Each table row shows performance measurements for this Haskell GHC program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 11 | 8.05 | 1,464 | 447 | ||
| 3 | 0.09 | 956 | 447 | ||
| 7 | 0.65 | 988 | 447 |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read recursive benchmark to see what this program should do.
{-# OPTIONS -O2 -fvia-C -fexcess-precision #-} -- -- The Computer Language Benchmarks Game -- http://shootout.alioth.debian.org/ -- -- Translated from the Clean by Don Stewart -- -- Should be compiled with: -- -O -fglasgow-exts -optc-march=pentium4 -- -optc-O2 -optc-mfpmath=sse -optc-msse2 -- import System import Numeric main = do n <- getArgs >>= readIO . head let m = n-1 a = 27 + fromIntegral n putStr $ line "Ack" [3,n] (ack 3 n) show ++ line "Fib" [a] (fib a :: Double) (\n -> showFFloat (Just 1) n []) ++ line "Tak" [3*m,2*m,m] (tak (3*m) (2*m) m :: Int) show ++ line "Fib" [3] (fib 3 :: Int) show ++ line "Tak" [3,2,1] (tak 3 2 1 :: Double) show where line pre a r f = pre ++ "(" ++ csv f a "" ++ "): " ++ f r ++ "\n" csv f [a] s = s ++ f a csv f (a:b) s = s ++ f a ++ "," ++ csv f b s ack :: Int -> Int -> Int ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1)) fib :: (Num a, Ord a) => a -> a fib n = if n >= 2 then fib (n-1) + fib (n-2) else 1 tak :: (Num a, Ord a) => a -> a -> a -> a tak x y z = if y < x then tak (tak (x-1) y z) (tak (y-1) z x) (tak (z-1) x y) else z
BUILD COMMANDS FOR: recursive.ghc Sat Jan 19 19:41:22 PST 2008 cp /home/dunham/gp4/shootout/bench/recursive/recursive.ghc recursive.hs /usr/bin/ghc --make -O2 -fglasgow-exts -optc-O2 -optc-mfpmath=sse -optc-msse2 -optc-march=pentium4 recursive.hs -o recursive.ghc_run [1 of 1] Compiling Main ( recursive.hs, recursive.o ) Linking recursive.ghc_run ... rm recursive.hs ================================================================= COMMAND LINE (%A is single numeric argument): recursive.ghc_run $MB_GHCRTS %A PROGRAM OUTPUT ============== Ack(3,11): 16381 Fib(38.0): 63245986.0 Tak(30,20,10): 11 Fib(3): 3 Tak(3.0,2.0,1.0): 2.0