module Test.SBench.Space.Single.Test
( getProfile
, getMaxMem
, getMaxMemWith
, getMemLine
, getMemLineWith
)
where
import System.FilePath ( FilePath )
import Test.SBench.Space.Single.MakeExecutable ( make )
import Test.SBench.Space.Single.RunExecutable ( run )
import qualified Test.SBench.Space.Single.ExploreProfile as Explore ( getMaxMem, getMemLine )
import Test.SBench.Options ( TestOpts(..), NormalInput, MemSize(..), MemUnit(..), Title, opts2string, EvalMod(..) )
import Test.SBench.STerm ( Algorithm(..), Data )
import Test.SBench.Space.OptionSet ( setRepetitions, addCC, defltTestOpts, setNfInput, setMemSizes )
import Test.SBench.File.FileOps ( series2sbench' )
getProfile :: TestOpts -> Algorithm (a -> b) -> Data a
-> FilePath -> IO FilePath
getProfile topts alg arg file = make topts alg arg file >>= run topts
getMaxMem :: NormalInput
-> Algorithm (a -> b)
-> Data a
-> FilePath
-> IO Integer
getMaxMem nfinp alg =
getMaxMemWith (setNfInput nfinp $ setMemSizes [Stack 500 M] $ setRepetitions 1 $ addCC alg $ defltTestOpts) alg
getMaxMemWith :: TestOpts -> Algorithm (a -> b) -> Data a -> FilePath -> IO Integer
getMaxMemWith topts alg arg file = getProfile topts alg arg file >>= Explore.getMaxMem
getMemLine :: NormalInput
-> (FilePath, Title)
-> Algorithm (a -> b)
-> Data a
-> IO [(Double, Integer)]
getMemLine nfinp store alg =
getMemLineWith (setNfInput nfinp $ setMemSizes [Stack 500 M] $ setRepetitions 1 $ addCC alg $ defltTestOpts) store alg
getMemLineWith :: TestOpts -> (FilePath, Title) -> Algorithm (a -> b) -> Data a -> IO [(Double, Integer)]
getMemLineWith topts (file, title) alg arg = do
s <- getProfile topts alg arg file >>= Explore.getMemLine
series2sbench' (opts2string (cOpts topts), show (rOpts topts)) (Just (if (nfInp topts) then NF else WHNF)) alg arg title file s
return s