aboutsummaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorTom Smeding <t.j.smeding@uu.nl>2025-02-21 13:35:26 +0100
committerTom Smeding <t.j.smeding@uu.nl>2025-02-21 13:35:26 +0100
commita17bd53598ee5266fc3a1c45f8f4bb4798dc495e (patch)
treeee7962f603fbb26a0df0f793b8e50666f41a0dfd /bench
parentb91d36fa38be07397b505433f24a6d29a79c2642 (diff)
Working tests and benchmarks against 'ad'
Diffstat (limited to 'bench')
-rw-r--r--bench/Main.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index a11f4e8..99c3f1d 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -4,11 +4,24 @@ module Main where
import Criterion
import Criterion.Main
+import qualified Numeric.AD as AD
+
import qualified Numeric.ADDual as ADD
import Numeric.ADDual.Examples
main :: IO ()
main = defaultMain
- [env (pure makeNeuralInput) $ \input ->
- bench "neural" $ nf (\inp -> ADD.gradient' @Double fneural inp 1.0) input]
+ [env (pure (makeNeuralInput 100)) $ \input ->
+ bgroup "neural-100"
+ [bench "dual" $ nf (\inp -> ADD.gradient' @Double fneural inp 1.0) input
+ ,bench "ad" $ nf (\inp -> AD.grad fneural inp) input]
+ ,env (pure (makeNeuralInput 500)) $ \input ->
+ bgroup "neural-500"
+ [bench "dual" $ nf (\inp -> ADD.gradient' @Double fneural inp 1.0) input
+ ,bench "ad" $ nf (\inp -> AD.grad fneural inp) input]
+ ,env (pure (makeNeuralInput 2000)) $ \input ->
+ bgroup "neural-2000"
+ [bench "dual" $ nf (\inp -> ADD.gradient' @Double fneural inp 1.0) input
+ ,bench "ad" $ nf (\inp -> AD.grad fneural inp) input]
+ ]