Skip to content

Instantly share code, notes, and snippets.

@tanakh
Created November 15, 2012 10:09
Show Gist options
  • Select an option

  • Save tanakh/4077813 to your computer and use it in GitHub Desktop.

Select an option

Save tanakh/4077813 to your computer and use it in GitHub Desktop.
C vs Python vs Ruby vs Haskell(無意味な処理deベンチマーク) ref: http://qiita.com/items/c53751e780a89941243a
mylist :: Int -> [[Int]]
mylist n = take n $ iterate (map (+n)) [1..n]
main :: IO ()
main = print.last.last $ map reverse $ mylist 4000
$ ghc -O2 muda.hs && time ./muda
15996001
real 0m2.164s
user 0m1.912s
sys 0m0.248s
mylist :: Int -> [[Int]]
mylist n = take n $ map (take n) $ iterate (drop n) [1..n^2]
main :: IO ()
main = print.last.last $ map reverse $ mylist 4000
$ ghc -O2 muda.hs && time ./muda
[1 of 1] Compiling Main ( muda.hs, muda.o )
Linking muda ...
15996001
real 0m0.565s
user 0m0.556s
sys 0m0.004s
mylist :: Int -> [[Int]]
mylist n =
[ take n [ i * n + 1 .. ]
| i <- [0 .. n - 1]
]
main :: IO ()
main = print.last.last $ map reverse $ mylist 4000
$ ghc -O2 muda.hs && time ./muda
[1 of 1] Compiling Main ( muda.hs, muda.o )
Linking muda ...
15996001
real 0m0.002s
user 0m0.000s
sys 0m0.000s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment