diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-06-12 08:03:38 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-06-12 08:03:38 +0000 |
commit | 3aba203e0c686039bc8c872ef6beb3843537a48a (patch) | |
tree | f6a38372762bbfcf1e60d972e9dc40d7eb9339f8 | |
parent | 42064526b944b6c0365105e4f3acc6bb1b38712e (diff) |
minor fix
-rw-r--r-- | examples/benchmarks.hs | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/examples/benchmarks.hs b/examples/benchmarks.hs index 5c52b3c..0859d8f 100644 --- a/examples/benchmarks.hs +++ b/examples/benchmarks.hs | |||
@@ -1,8 +1,8 @@ | |||
1 | {-# OPTIONS -fbang-patterns #-} | 1 | {-# OPTIONS -fbang-patterns #-} |
2 | 2 | ||
3 | -- compile as: | 3 | -- compile as: |
4 | -- ghc --make -O2 -optc-O2 -fvia-C benchmarks.hs -o benchmarks | 4 | -- ghc --make -O2 -optc-O2 -fvia-C benchmarks.hs |
5 | -- ghc --make -O benchmarks.hs -o benchmarks | 5 | -- ghc --make -O benchmarks.hs |
6 | 6 | ||
7 | import Numeric.LinearAlgebra | 7 | import Numeric.LinearAlgebra |
8 | import System.Time | 8 | import System.Time |
@@ -15,13 +15,7 @@ time act = do | |||
15 | t0 <- getCPUTime | 15 | t0 <- getCPUTime |
16 | act | 16 | act |
17 | t1 <- getCPUTime | 17 | t1 <- getCPUTime |
18 | printf "%.2f CPU seconds\n" $ (fromIntegral ((t1 - t0) `div` (10^10)) / 100 :: Double) :: IO () | 18 | printf "%.3f s CPU\n" $ (fromIntegral (t1 - t0) / (10^12 :: Double)) :: IO () |
19 | |||
20 | time' act = do | ||
21 | t0 <- getClockTime | ||
22 | act | ||
23 | t1 <- getClockTime | ||
24 | putStrLn $ timeDiffToString $ normalizeTimeDiff $ diffClockTimes t1 t0 | ||
25 | 19 | ||
26 | -------------------------------------------------------------------------------- | 20 | -------------------------------------------------------------------------------- |
27 | 21 | ||
@@ -31,7 +25,7 @@ w :: Vector Double | |||
31 | w = constant 1 30000000 | 25 | w = constant 1 30000000 |
32 | 26 | ||
33 | bench1 = do | 27 | bench1 = do |
34 | putStrLn "sum of a vector with 30 million doubles:" | 28 | putStrLn "Sum of a vector with 30M doubles:" |
35 | print$ vectorMax w -- evaluate it | 29 | print$ vectorMax w -- evaluate it |
36 | time $ printf " BLAS: %.2f: " $ sumVB w | 30 | time $ printf " BLAS: %.2f: " $ sumVB w |
37 | time $ printf " Haskell: %.2f: " $ sumVH w | 31 | time $ printf " Haskell: %.2f: " $ sumVH w |
@@ -51,11 +45,11 @@ sumVH v = go (d - 1) 0 | |||
51 | 45 | ||
52 | bench2 = do | 46 | bench2 = do |
53 | putStrLn "-------------------------------------------------------" | 47 | putStrLn "-------------------------------------------------------" |
54 | putStrLn "multiplication of one million different 3x3 matrices" | 48 | putStrLn "Multiplication of 1M different 3x3 matrices:" |
55 | putStrLn "from [[]]" | 49 | -- putStrLn "from [[]]" |
56 | time $ print $ fun (10^6) rot' | 50 | -- time $ print $ fun (10^6) rot' |
57 | putStrLn "from []" | 51 | -- putStrLn "from []" |
58 | time $ print $ fun (10^6) rot | 52 | time $ print $ manymult (10^6) rot |
59 | print $ cos (10^6/2) | 53 | print $ cos (10^6/2) |
60 | 54 | ||
61 | 55 | ||
@@ -74,5 +68,5 @@ rot a = (3><3) [ c,0,s | |||
74 | where c = cos a | 68 | where c = cos a |
75 | s = sin a | 69 | s = sin a |
76 | 70 | ||
77 | fun n r = foldl1' (<>) (map r angles) | 71 | manymult n r = foldl1' (<>) (map r angles) |
78 | where angles = toList $ linspace n (0,1) | 72 | where angles = toList $ linspace n (0,1) |