aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bench/Main.hs54
-rw-r--r--ox-arrays.cabal7
2 files changed, 58 insertions, 3 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index cc4e11f..f3068d8 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -4,6 +4,7 @@
module Main where
import Data.Array.RankedS qualified as RS
+import Data.Vector.Storable qualified as VS
import Numeric.LinearAlgebra qualified as LA
import Test.Tasty.Bench
@@ -12,6 +13,14 @@ import Data.Array.Nested.Internal.Mixed (mliftPrim, mliftPrim2)
import Data.Array.Nested.Internal.Ranked (arithPromoteRanked, arithPromoteRanked2)
+enableMisc :: Bool
+enableMisc = False
+
+bgroupIf :: Bool -> String -> [Benchmark] -> Benchmark
+bgroupIf True = bgroup
+bgroupIf False = \name _ -> bgroup name []
+
+
main :: IO ()
main = defaultMain
[bgroup "Num"
@@ -132,4 +141,49 @@ main = defaultMain
in nf (\a -> RS.normalize a)
(RS.rev [0] (RS.rev [0] (RS.iota @Double n)))
]
+ ,bgroupIf enableMisc "misc"
+ [let n = 1000
+ k = 1000
+ in bgroup ("fusion [" ++ show k ++ "]*" ++ show n) $
+ [bench "sum (concat)" $
+ nf (\as -> VS.sum (VS.concat as))
+ (replicate n (VS.enumFromTo (1::Int) k))
+ ,bench "sum (force (concat))" $
+ nf (\as -> VS.sum (VS.force (VS.concat as)))
+ (replicate n (VS.enumFromTo (1::Int) k))]
+ ,bgroup "concat"
+ [bgroup "N"
+ [bgroup "hmatrix"
+ [bench ("LA.vjoin [500]*1e" ++ show ni) $
+ let n = 10 ^ ni
+ k = 500
+ in nf (\as -> LA.vjoin as)
+ (replicate n (VS.enumFromTo (1::Int) k))
+ | ni <- [1::Int ..5]]
+ ,bgroup "vectorStorable"
+ [bench ("VS.concat [500]*1e" ++ show ni) $
+ let n = 10 ^ ni
+ k = 500
+ in nf (\as -> VS.concat as)
+ (replicate n (VS.enumFromTo (1::Int) k))
+ | ni <- [1::Int ..5]]
+ ]
+ ,bgroup "K"
+ [bgroup "hmatrix"
+ [bench ("LA.vjoin [1e" ++ show ki ++ "]*500") $
+ let n = 500
+ k = 10 ^ ki
+ in nf (\as -> LA.vjoin as)
+ (replicate n (VS.enumFromTo (1::Int) k))
+ | ki <- [1::Int ..5]]
+ ,bgroup "vectorStorable"
+ [bench ("VS.concat [1e" ++ show ki ++ "]*500") $
+ let n = 500
+ k = 10 ^ ki
+ in nf (\as -> VS.concat as)
+ (replicate n (VS.enumFromTo (1::Int) k))
+ | ki <- [1::Int ..5]]
+ ]
+ ]
+ ]
]
diff --git a/ox-arrays.cabal b/ox-arrays.cabal
index 9153336..2de5a6d 100644
--- a/ox-arrays.cabal
+++ b/ox-arrays.cabal
@@ -56,7 +56,7 @@ library
cc-options: -msse2
default-language: Haskell2010
- ghc-options: -Wall
+ ghc-options: -Wall -O2
other-extensions: TemplateHaskell
test-suite test
@@ -101,7 +101,8 @@ benchmark bench
base,
hmatrix,
orthotope,
- tasty-bench
+ tasty-bench,
+ vector
hs-source-dirs: bench
default-language: Haskell2010
- ghc-options: -Wall
+ ghc-options: -Wall -O2