import Criterion.Main

import Dodge.RandomHelp

import Geometry
import Dodge.Creature.Inanimate

import System.Random
import Control.Monad (replicateM)
import Data.Functor ((<&>))
import Control.Monad.State
import Data.List (zip4)

main :: IO ()
main = do
    [ps1, ps2, ps3, ps4] <- mapM randomPoints [5,10,50,500]
--    fs <- replicateM 500 (randomRIO (1,20))
    defaultMain
        [ bgroup "polyToTris tests"
            [ bench "polyToTris 5" $ nf polyToTris ps1          
            , bench "polyToTris 10" $ nf polyToTris ps2          
            , bench "polyToTris 50" $ nf polyToTris ps3          
            , bench "polyToTris 500" $ nf polyToTris ps4          
            ]
        , bgroup "polyToTriFold tests"
            [ bench "polyToTriFold 5" $ nf polyToTris'' ps1          
            , bench "polyToTriFold 10" $ nf polyToTris'' ps2          
            , bench "polyToTriFold 50" $ nf polyToTris'' ps3          
            , bench "polyToTriFold 500" $ nf polyToTris'' ps4          
            ]
        ]

uncurry4 f (a,b,c,d) = f a b c d

randomPoints :: Int -> IO [Point2]
randomPoints i = getStdGen <&> evalState (replicateM i $ randInCirc 500)
