summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-10-27 17:00:07 +0000
committerAlberto Ruiz <aruiz@um.es>2008-10-27 17:00:07 +0000
commit86c7aed1de8efe5988f994867d35addb6b62a655 (patch)
tree01062a04188f8a8e06aa76e0287ea99caf6f2343 /examples
parentedf12982f21c56c21bfc21eb2b2fcbc406838130 (diff)
simplified README
Diffstat (limited to 'examples')
-rw-r--r--examples/benchmarks.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/benchmarks.hs b/examples/benchmarks.hs
index 517d402..78c1e5f 100644
--- a/examples/benchmarks.hs
+++ b/examples/benchmarks.hs
@@ -1,8 +1,7 @@
1{-# LANGUAGE BangPatterns #-} 1{-# LANGUAGE BangPatterns #-}
2 2
3-- compile as: 3-- $ ghc --make -O2 benchmarks.hs
4-- ghc --make -O2 -optc-O2 -fvia-C benchmarks.hs 4
5-- ghc --make -O benchmarks.hs
6 5
7import Numeric.LinearAlgebra 6import Numeric.LinearAlgebra
8import System.Time 7import System.Time
@@ -22,11 +21,11 @@ time act = do
22main = sequence_ [bench1,bench2,bench3,bench4] 21main = sequence_ [bench1,bench2,bench3,bench4]
23 22
24w :: Vector Double 23w :: Vector Double
25w = constant 1 30000000 24w = constant 1 5000000
26w2 = 1 * w 25w2 = 1 * w
27 26
28bench1 = do 27bench1 = do
29 putStrLn "Sum of a vector with 30M doubles:" 28 putStrLn "Sum of a vector with 5M doubles:"
30 print$ vectorMax (w+w2) -- evaluate it 29 print$ vectorMax (w+w2) -- evaluate it
31 time $ printf " BLAS: %.2f: " $ sumVB w 30 time $ printf " BLAS: %.2f: " $ sumVB w
32 time $ printf " Haskell: %.2f: " $ sumVH w 31 time $ printf " Haskell: %.2f: " $ sumVH w
@@ -91,7 +90,7 @@ bench3 = do
91 let v = flatten $ ident 500 :: Vector Double 90 let v = flatten $ ident 500 :: Vector Double
92 print $ vectorMax v -- evaluate it 91 print $ vectorMax v -- evaluate it
93 92
94 putStrLn "sum, dim=30M:" 93 putStrLn "sum, dim=5M:"
95 -- time $ print $ foldLoop (\k s -> w@>k + s) 0.0 (dim w) 94 -- time $ print $ foldLoop (\k s -> w@>k + s) 0.0 (dim w)
96 time $ print $ sumVector w 95 time $ print $ sumVector w
97 96
@@ -114,7 +113,7 @@ foldVector f s v = foldLoop g s (dim v)
114 113
115sumVector = foldVector (\k v s -> v k + s) 0.0 114sumVector = foldVector (\k v s -> v k + s) 0.0
116 115
117-- foldVector is slower if it is used in two places unles we use the above INLINE 116-- foldVector is slower if used in two places unless we use the above INLINE
118-- this does not happen with foldLoop 117-- this does not happen with foldLoop
119-------------------------------------------------------------------------------- 118--------------------------------------------------------------------------------
120 119