Commits

Aleksey Khudyakov committed e1f947f

More regular benchmark for logGamma* functions

Comments (0)

Files changed (1)

benchmark/bench.hs

 import Numeric.SpecFunctions
 import Text.Printf
 
+-- Uniformly sample logGamma performance between 10^-6 to 10^6
+benchmarkLogGamma logG =
+  [ bench (printf "%.3g" x) $ nf logG x
+  | x <- [ m * 10**n | n <- [ -8 .. 8 ]
+                     , m <- [ 10**(i / tics) | i <- [0 .. tics-1] ]
+         ]
+  ]
+  where tics = 3
+{-# INLINE benchmarkLogGamma #-}
+
 main :: IO ()
 main = defaultMain 
-  [ bgroup "logGamma" 
-    [ bench (printf "%.3f" x) $ nf logGamma x
-    | x <- [ 0.1,0.4,0.8                  -- [0     .. 1.5  ]
-           , 2, 3.5                       -- [1.5   .. 4    ]
-           , 5, 7, 11                     -- [4     .. 12   ]
-           , 100, 300, 1e3, 3e3, 1e4, 3e4 -- [12    .. 5.1e4]
-           , 6e4                          -- [5.1e4 .. +∞   ]
-           ]
-    ]
-  , bgroup "logGammaL"
-    [ bench (printf "%.3f" x) $ nf logGammaL x
-    | x <- [ 1e-1, 3e-1, 1e+0, 3e+0
-           , 1e+1, 3e+1, 1e+2, 3e+2 
-           , 1e+3, 3e+3, 1e+4, 3e+4 
-           ]
-    ]
+  [ bgroup "logGamma" $
+    benchmarkLogGamma logGamma
+  , bgroup "logGammaL" $
+    benchmarkLogGamma logGammaL
   , bgroup "factorial"
     [ bench (show n) $ nf factorial n
     | n <- [ 0, 1, 3, 6, 9, 11, 15