aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-20 23:26:11 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-20 23:26:11 +0200
commite1467acc516609c24095d048f992f63cc306d99a (patch)
tree02aa88991249a52f7792c30f9299e175614ac2ff
parentd8d8fc39c6d52b0960c89f38bfa8ec3969a8ca02 (diff)
WIP benchmark file
-rw-r--r--bench/Main.hs20
-rw-r--r--ox-arrays.cabal11
2 files changed, 31 insertions, 0 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
new file mode 100644
index 0000000..d8582fe
--- /dev/null
+++ b/bench/Main.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE NumericUnderscores #-}
+{-# LANGUAGE TypeApplications #-}
+module Main where
+
+import Test.Tasty.Bench
+
+import Data.Array.Nested
+
+
+main :: IO ()
+main = defaultMain
+ [bgroup "Num"
+ [bench "sum(+) Double [1e6]" $
+ let n = 1_000_000
+ in nf (\(a, b) -> runScalar (rsumOuter1 (a + b)))
+ (riota @Double n, riota n)
+ ,bench "sum(*) Double [1e6]" $
+ let n = 1_000_000
+ in nf (\(a, b) -> runScalar (rsumOuter1 (a + b)))
+ (riota @Double n, riota n)]]
diff --git a/ox-arrays.cabal b/ox-arrays.cabal
index d39d5e5..58fccf9 100644
--- a/ox-arrays.cabal
+++ b/ox-arrays.cabal
@@ -29,3 +29,14 @@ test-suite example
hs-source-dirs: example
default-language: Haskell2010
ghc-options: -Wall
+
+benchmark bench
+ type: exitcode-stdio-1.0
+ main-is: Main.hs
+ build-depends:
+ ox-arrays,
+ base,
+ tasty-bench
+ hs-source-dirs: bench
+ default-language: Haskell2010
+ ghc-options: -Wall