Create basic benchmarks for circOnLine

This commit is contained in:
jgk
2021-04-01 19:33:04 +02:00
parent cbcc0f700b
commit 91e6e44f45
2 changed files with 23 additions and 1 deletions
+22 -1
View File
@@ -1,4 +1,25 @@
import Criterion.Main
import Dodge.RandomHelp
import Geometry
import System.Random
import Control.Monad.State
import Data.List (zip4)
main :: IO ()
main = putStrLn "h"
main = do
[ps1, ps2, ps3, ps4] <- mapM randomPoints [500,500,500,500]
fs <- sequence $ replicate 500 (randomRIO (1,20))
defaultMain
[ bgroup "circLine tests"
[ bench "circLine" $ nf (map $ uncurry4 circOnLine) (zip4 ps1 ps2 ps3 fs)
, bench "circLine'" $ nf (map $ uncurry4 circOnLine') (zip4 ps1 ps2 ps3 fs)
]
]
uncurry4 f (a,b,c,d) = f a b c d
randomPoints :: Int -> IO [Point2]
randomPoints i = getStdGen >>= return . evalState (sequence $ replicate i $ randInCirc 500)
+1
View File
@@ -84,6 +84,7 @@ benchmarks:
loop-benchmarks:
dependencies:
- criterion
- loop
ghc-options:
- -threaded
- -O2