aboutsummaryrefslogtreecommitdiff
path: root/bench/Main.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-11-26 22:44:44 +0100
committerTom Smeding <tom@tomsmeding.com>2025-11-26 22:44:44 +0100
commit829109ba73211394691d5789f35a23120feaf3f6 (patch)
treedf523326d0a7f6c6698e2b1aae7d177c17de792a /bench/Main.hs
parent2177f3e9cdb8a1f10529f678d5dad9d8c7d60d86 (diff)
Benchmark and improve ixxFromLinear
Diffstat (limited to 'bench/Main.hs')
-rw-r--r--bench/Main.hs21
1 files changed, 12 insertions, 9 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index 8df09a9..01d9a3f 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -17,19 +17,12 @@ import Text.Show (showListWith)
import Data.Array.Nested
import Data.Array.Nested.Mixed (Mixed(M_Primitive), mliftPrim, mliftPrim2, toPrimitive)
+import Data.Array.Nested.Mixed.Shape
import Data.Array.Nested.Ranked (liftRanked1, liftRanked2)
import Data.Array.Strided.Arith.Internal qualified as Arith
import Data.Array.XArray (XArray(..))
-enableMisc :: Bool
-enableMisc = False
-
-bgroupIf :: Bool -> String -> [Benchmark] -> Benchmark
-bgroupIf True = bgroup
-bgroupIf False = \name _ -> bgroup name []
-
-
main :: IO ()
main = do
let enable = False
@@ -104,7 +97,7 @@ main_tests = defaultMain
in nf (\a -> RS.normalize a)
(RS.rev [0] (RS.rev [0] (RS.iota @Double n)))
]
- ,bgroupIf enableMisc "misc"
+ ,bgroup "misc"
[let n = 1000
k = 1000
in bgroup ("fusion [" ++ show k ++ "]*" ++ show n)
@@ -148,6 +141,16 @@ main_tests = defaultMain
| ki <- [1::Int ..5]]
]
]
+ ,bench "ixxFromLinear 10000x" $
+ let n = 10000
+ sh0 = SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% ZSX
+ in nf (\sh -> [ixxFromLinear sh i | i <- [1..n]]) sh0
+ ,bench "ixxFromLinear 1x" $
+ let sh0 = SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% ZSX
+ in nf (\sh -> ixxFromLinear sh 1234) sh0
+ ,bench "shxEnum" $
+ let sh0 = SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% SUnknown 10 :$% ZSX
+ in nf (\sh -> shxEnum sh) sh0
]
]