diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-06-12 22:08:52 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-06-12 22:08:52 +0200 |
commit | 50fa6c2bb89162d2b6d5902c43c4857dbd2dca14 (patch) | |
tree | 174707f07fc1cae4dd0235ffacfaeb75c35d868e | |
parent | a088130c3e722d3c589be388a98daab28a73b23f (diff) |
Vector stuff needs -O2; let's set it
-rw-r--r-- | bench/Main.hs | 54 | ||||
-rw-r--r-- | ox-arrays.cabal | 7 |
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 |