module Test.SBench.Space.Series.Test (
makeSeries
, maxMemSeries
, maxMemSeriesWith
) where
import Test.SBench.Options ( NormalInput, TestOpts(..) )
import Test.SBench.STerm ( Algorithm, DataGen, Seed, Data, STerm(..), (<$>) )
import Test.SBench.Space.OptionSet ( setNfInput, addCC, defltTestOpts )
import Test.SBench.Space.Single.Test ( getMaxMemWith )
import Test.SBench.Options ( opts2string, Title )
import Test.SBench.File.FileOps ( series2sbench )
import System.FilePath ( FilePath )
import Control.Monad ( liftM )
makeSeries :: (Show c, Real c, Show d, Real d) =>
(TestOpts -> Algorithm (a -> b) -> Data a -> FilePath -> IO d)
-> TestOpts
-> (FilePath, Title)
-> Algorithm (a -> b)
-> DataGen (c -> a)
-> [Seed c]
-> IO [(c, d)]
makeSeries fun topts (outf, title) alg gen seeds =
let b = opts2string $ cOpts topts
r = show $ rOpts topts
in do
s <- liftM (zip (map stTerm seeds)) (mapM go seeds)
series2sbench (b, r) Nothing alg gen title outf s >> return s
where
tst = fun topts alg
go i = tst (gen <$> i) (outf ++ stName i)
maxMemSeries :: (Show c, Real c) =>
NormalInput
-> (FilePath, Title)
-> Algorithm (a -> b)
-> DataGen (c -> a)
-> [Seed c]
-> IO [(c, Integer)]
maxMemSeries nfinp ft alg = maxMemSeriesWith (setNfInput nfinp $ addCC alg $ defltTestOpts) ft alg
maxMemSeriesWith :: (Show c, Real c) => TestOpts -> (FilePath, Title) -> Algorithm (a -> b) -> DataGen (c -> a) -> [Seed c] -> IO [(c, Integer)]
maxMemSeriesWith topts ft alg gen seeds =
makeSeries getMaxMemWith topts ft alg gen seeds