packages feed

SBench 0.1.1 → 0.2.0

raw patch · 10 files changed

+56/−45 lines, 10 filesdep +bytestringdep +cassavadep +processdep −haskell98dep −txt-sushidep ~basedep ~criteriondep ~directory

Dependencies added: bytestring, cassava, process, utf8-string, vector

Dependencies removed: haskell98, txt-sushi

Dependency ranges changed: base, criterion, directory, gnuplot, hp2any-core

Files

SBench.cabal view
@@ -1,6 +1,6 @@ Name:                SBench -Version:             0.1.1+Version:             0.2.0  Synopsis:            A benchmark suite for runtime and heap measurements over                       a series of inputs.@@ -56,16 +56,19 @@     Test.SBench.Space.Series.Test    Build-depends:-    base >= 4 && <5, -    criterion >= 0.5 && <0.6,-    gnuplot >= 0.4.0.1 && <0.5,-    hp2any-core, +    base >= 4 && <6, +    criterion >= 0.5,+    gnuplot >= 0.4.0.1,+    hp2any-core >= 0.11.2,      deepseq,-    txt-sushi >= 0.5 && <0.6,+    cassava >= 0.2.1.2,     parsec >= 3 && <= 4, -    directory >= 1 && <2, +    directory >= 1,      filepath,-    haskell98+    vector,+    process,+    utf8-string,+    bytestring      Other-modules:            Test.SBench.File.Parser
example/Test.hs view
@@ -1,6 +1,6 @@ module Main where -import System ( getArgs )+import System.Environment ( getArgs )  import NFib ( nFib1, nFib2 ) @@ -73,8 +73,8 @@ main = do     let bOpts = "unknown"         rOpts = "unknown"-    print bOpts-    print rOpts+    putStrLn bOpts+    putStrLn rOpts     doRuntimeTests bOpts rOpts     doMemProfile     doMaxMemSeries
src/Test/SBench/File/FileOps.hs view
@@ -5,7 +5,11 @@   , sbench2series   ) where -import Database.TxtSushi.FlatFile (csvFormat, parseTable)+--import Database.TxtSushi.FlatFile (csvFormat, parseTable)+import Data.Csv ( decode )+import qualified Data.Vector as V ( Vector, head, tail, findIndex, toList, map, (!) )+import qualified Data.ByteString.Lazy as LBS ( ByteString, unpack, pack )+import qualified Codec.Binary.UTF8.String as UTF8 ( encode ) import System.IO ( FilePath, openFile, hClose, hGetContents, hPutStr, IOMode (..) ) import System.Directory ( doesFileExist ) import System.FilePath ( addExtension, dropExtension, takeExtension )@@ -35,11 +39,15 @@       then         do           filecont <- myReadFile fin-          let (header : body) = parseTable csvFormat filecont-              meanIndex = findIndex ( == "Mean") header+          all      <- case decode False (LBS.pack $ UTF8.encode filecont) :: Either String (V.Vector (V.Vector String)) of +                        Left s     -> fail s+                        Right dat  -> return dat+          let header = V.head all+              body   = V.tail all+              meanIndex = V.findIndex (== "Mean") header           case meanIndex of             Nothing -> error $ "Criterion-File " ++ " is in a wrong format."-            Just i  -> return $ map (!! i) body+            Just i  -> return $ V.toList $ V.map ((V.! i)) body       else error $ "File " ++ fin ++ " does not exist."  -- | Read the mean runtimes of a criterion data file and tuple them with seeds@@ -54,7 +62,7 @@  -- | Store a series of measurements over /different inputs/ in a .sbench file. --   The SBench file format take some extra information about the measurement.-series2sbench :: (Real a, Real b) => +series2sbench :: (Show a, Real a, Show b, Real b) =>                      (String, String)    -- ^ (build options, runtime options) used for the measurement.                  -> Maybe EvalMod       -- ^ Evaluation mode for the input (e.g. as given to criterion for time measurements)                  -> Algorithm (c -> d)  -- ^ The function tested.@@ -66,11 +74,11 @@ series2sbench (bOpts, eOpts) evMod alg gen title file ser = do       let mi = prepareMetaInfo           fout = (addExtension (dropExtension file) "sbench")-      print $ "creating sbench data file " ++ fout ++ "..."+      putStrLn $ "creating sbench data file " ++ fout ++ "..."       generateFile mi ser fout       return fout     where-      generateFile :: (Real a, Real b) => MetaInfo a b -> [(a, b)] -> FilePath -> IO ()+      generateFile :: (Show a, Real a, Show b, Real b) => MetaInfo a b -> [(a, b)] -> FilePath -> IO ()       generateFile mi ser fout =         myWriteFile fout $ show mi ++ toGNUStyle ser       prepareMetaInfo =@@ -92,7 +100,7 @@  -- | Store a series of measurements with /a single input/ in a .sbench file. --   The SBench file format take some extra information about the measurement.-series2sbench' :: (Real a, Real b) => +series2sbench' :: (Show a, Real a, Show b, Real b) =>                       (String, String)    -- ^ (build options, runtime options) used for the measurement.                   -> Maybe EvalMod       -- ^ Evaluation mode for the input (e.g. as given to criterion for time measurements)                   -> Algorithm (c -> d)  -- ^ The function tested.@@ -104,11 +112,11 @@ series2sbench' (bOpts, eOpts) evMod alg inp title file ser = do       let mi = prepareMetaInfo           fout = (addExtension (dropExtension file) "sbench")-      print $ "creating sbench data file " ++ fout ++ "..."+      putStrLn $ "creating sbench data file " ++ fout ++ "..."       generateFile mi ser fout       return fout     where-      generateFile :: (Real a, Real b) => MetaInfo a b -> [(a, b)] -> FilePath -> IO ()+      generateFile :: (Show a, Real a, Show b, Real b) => MetaInfo a b -> [(a, b)] -> FilePath -> IO ()       generateFile mi ser fout =         myWriteFile fout $ show mi ++ toGNUStyle ser       prepareMetaInfo =
src/Test/SBench/File/Types.hs view
@@ -17,7 +17,7 @@   , exeOptions       :: String   } -instance (Real a, Real b) => Show (MetaInfo a b) where+instance (Show a, Real a, Show b, Real b) => Show (MetaInfo a b) where     show = showMetaInfo  showMetaInfo mi = foldr (\x y -> x ++ "\n" ++ y) "" lines
src/Test/SBench/Plot/Gnuplot.hs view
@@ -28,7 +28,7 @@ import qualified Graphics.Gnuplot.Graph as Graph import Data.Monoid ( mappend, mempty ) import System.FilePath ( (<.>) )-import System ( system )+import System.Process ( system ) import Test.SBench.Options ( Title ) import Test.SBench.File.FileOps ( sbench2series ) import Test.SBench.File.Types ( MetaInfo(..) )
src/Test/SBench/STerm.hs view
@@ -62,7 +62,7 @@ toNamedData :: (Show a) => a -> TermName -> STerm a toNamedData a n = T a n [] [] -makeSeeds :: (Integral a) +makeSeeds :: (Show a, Integral a)            => a -- ^ minimal value           -> a -- ^ maximal value           -> a -- ^ number of seeds
src/Test/SBench/Space/Series/Test.hs view
@@ -14,7 +14,7 @@ import System.FilePath ( FilePath ) import Control.Monad ( liftM ) -makeSeries :: (Real c, Real d) =>+makeSeries :: (Show c, Real c, Show d, Real d) =>                  (TestOpts -> Algorithm (a -> b) -> Data a -> FilePath -> IO d) -- ^ Function for a single test.               -> TestOpts                          -> (FilePath, Title)   -- ^ File where the result data should be stored and title for the@@ -35,7 +35,7 @@  -- | The function measures the maximal heap consumption of a given function over a series of different inputs --   that are produced via an input generator given different seeds.-maxMemSeries :: Real c => +maxMemSeries :: (Show c, Real c) =>                     NormalInput            -- ^ Shall input data first be normalized? (Boolean value)                    -> (FilePath, Title)   -- ^ Output data file (will get extension .sbench) and title for the                                           --   graph of the data stored as meta information.@@ -47,6 +47,6 @@  -- | The function acts similar to 'maxMemSeries', but instead of only 'NormalInput', 'TestOpts' can be set manually --   via the first parameter.-maxMemSeriesWith :: Real c => TestOpts -> (FilePath, Title) -> Algorithm (a -> b) -> DataGen (c -> a) -> [Seed c] -> IO [(c, Integer)]+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
src/Test/SBench/Space/Single/MakeExecutable.hs view
@@ -5,7 +5,7 @@   where  import System.FilePath ( FilePath, addExtension )-import System ( system )+import System.Process ( system ) import System.IO ( writeFile ) import Data.Maybe ( fromMaybe ) import Control.Monad ( liftM2 )@@ -34,11 +34,11 @@       strcopts  = opts2string $ generalCOpts ++ copts       autoGen   = calcRepetitions nfinp copts f a   in do-        print $ "The repetitions: " ++ show rep-        print $ "Input normalized: " ++ show nfinp+        putStrLn $ "The repetitions: " ++ show rep+        putStrLn $ "Input normalized: " ++ show nfinp         rep' <- case rep of { Nothing -> autoGen; Just r -> return r }         writeFile (addExtension out "hs") (makeContent nfinp rep' f a)-        print $ "running: ghc " ++ strcopts ++ " -o " ++ out ++ " " ++ source+        putStrLn $ "running: ghc " ++ strcopts ++ " -o " ++ out ++ " " ++ source         system $ "ghc " ++ strcopts ++ " -o " ++ out ++ " " ++ source         return out @@ -52,19 +52,19 @@ calcRepetitions' nfinp rep copts f a =   do      writeFile "rep_check.hs" (makeContent nfinp rep f a)-     print $ "Calculating reasonable number of repetitions trying with " ++ show rep ++ " ..."+     putStrLn $ "Calculating reasonable number of repetitions trying with " ++ show rep ++ " ..."      system $ "ghc " ++ opts2string ("--make" : copts) ++ " -o rep_check rep_check.hs"-     print $ "start executing rep_check ..."+     putStrLn $ "start executing rep_check ..."      system "chmod +x rep_check"      (t, _) <- time $ system "./rep_check"-     print $ "... finish executing rep_check"-     print $ "Time was " ++ show t ++ " seconds."+     putStrLn $ "... finish executing rep_check"+     putStrLn $ "Time was " ++ show t ++ " seconds."      if t > 0.001        then            do             let reps' = truncate $ 1 * fromIntegral rep / t + 1                 reps  = max reps' 100-            print $ "Testing with " ++ show reps ++ " repetitions (expecting at least 1s runtime without profiling, but quarantee at least 100 runs)"+            putStrLn $ "Testing with " ++ show reps ++ " repetitions (expecting at least 1s runtime without profiling, but quarantee at least 100 runs)"             return reps        else calcRepetitions' nfinp (10 * rep) copts f a         @@ -85,7 +85,7 @@       ++ "        res  = map "           ++ stName f ++ " as \n"       ++ "        as = take " ++ show rep ++ " (repeat dat') in \n"-      ++ "    deepseq res (print \"Done.\")"+      ++ "    deepseq res (putStrLn \"Done.\")"   
src/Test/SBench/Space/Single/RunExecutable.hs view
@@ -5,7 +5,7 @@   where  import System.FilePath ( FilePath, addExtension, isRelative )-import System ( system )+import System.Process ( system )  import Test.SBench.Options (      TestOpts (..)@@ -39,6 +39,6 @@                 , opts2string (map show mopts)                 , opts2string (map show popts)                 ]-    print $ "call the following program:\n" ++ call ++ "\n"+    putStrLn $ "call the following program:\n" ++ call ++ "\n"     system call     return $ addExtension exe "hp"
src/Test/SBench/Time/Series/Test.hs view
@@ -33,7 +33,7 @@ defltCriterionFile = "temp" <.> "csv"  -- | Most general function to perform runtime measurements for a series of inputs.-runtimeSeriesWith :: (Control.DeepSeq.NFData b, Real c) => +runtimeSeriesWith :: (Control.DeepSeq.NFData b, Show c, Real c) =>                          Config  -- ^ see "Criterion.Config.Config"                      -> EvalMod -- ^ Evaluation level of the input before starting the measurement.                                 --   Either weak head normal form ('WHNF') or normal form ('NF')@@ -49,9 +49,9 @@                                            --   be generated via "Test.SBench.Auxiliar.Datagen.makeGens"                      -> IO [(c, Double)]   -- ^ series of the measurements as seed-runtime pairs. runtimeSeriesWith cfg evalMod sbfile alg gen seeds = do-    print "enter criterion benchmarking .."+    putStrLn "enter criterion benchmarking .."     t <- defaultMainWith cfg (return ()) benches-    print $ "finished criterion benchmarking with " ++ show t+    putStrLn $ "finished criterion benchmarking with " ++ show t     s <- criterion2series (map stTerm seeds) file     case sbfile of       Nothing -> return s@@ -68,7 +68,7 @@                 WHNF -> whnf  -- | As 'runtimeSeriesWith', but "Criterion.Config.Config" is set to a default.-runtimeSeries :: (Control.DeepSeq.NFData b, Real c) => +runtimeSeries :: (Control.DeepSeq.NFData b, Show c, Real c) =>                      EvalMod                  -> Maybe (BuildOptions, ExeOptions, FilePath, Title)                   -> Algorithm (a -> b) @@ -78,7 +78,7 @@ runtimeSeries = runtimeSeriesWith defaultConfig {cfgSummaryFile = Last $ Just $ defltCriterionFile }  -nfRuntimeSeries :: (Control.DeepSeq.NFData b, Real c) => +nfRuntimeSeries :: (Control.DeepSeq.NFData b, Show c, Real c) =>                        Maybe (BuildOptions, ExeOptions, FilePath, Title)                     -> Algorithm (a -> b)                     -> DataGen (c -> a) @@ -86,7 +86,7 @@                    -> IO [(c, Double)] nfRuntimeSeries = runtimeSeries NF  -whnfRuntimeSeries :: (Control.DeepSeq.NFData b, Real c) => +whnfRuntimeSeries :: (Control.DeepSeq.NFData b, Show c, Real c) =>                          Maybe (BuildOptions, ExeOptions, FilePath, Title)                      -> Algorithm (a -> b)                      -> DataGen (c -> a)