criterion 0.8.0.1 → 0.8.0.2
raw patch · 3 files changed
+19/−15 lines, 3 filesdep +textdep ~hastache
Dependencies added: text
Dependency ranges changed: hastache
Files
- Criterion/IO.hs +1/−0
- Criterion/Report.hs +15/−13
- criterion.cabal +3/−2
Criterion/IO.hs view
@@ -23,6 +23,7 @@ import Data.Binary (Binary(..), encode) import Data.Binary.Get (runGetOrFail) import Data.Binary.Put (putByteString, putWord16be, runPut)+import Data.ByteString.Char8 () import Data.Version (Version(..)) import Paths_criterion (version) import System.IO (Handle, IOMode(..), withFile)
Criterion/Report.hs view
@@ -44,8 +44,10 @@ import Text.Hastache (MuType(..)) import Text.Hastache.Context (mkGenericContext, mkStrContext, mkStrContextM) import qualified Control.Exception as E-import qualified Data.ByteString.Char8 as B-import qualified Data.ByteString.Lazy as L+import qualified Data.Text as T+import qualified Data.Text.IO as T+import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.IO as TL import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed as U import qualified Text.Hastache as H@@ -73,13 +75,13 @@ Last Nothing -> return () Last (Just name) -> liftIO $ do tpl <- loadTemplate [".",templateDir] (fromLJ cfgTemplate cfg)- L.writeFile name =<< formatReport reports tpl+ TL.writeFile name =<< formatReport reports tpl -- | Format a series of 'Report' values using the given Hastache -- template. formatReport :: [Report]- -> B.ByteString -- ^ Hastache template.- -> IO L.ByteString+ -> T.Text -- ^ Hastache template.+ -> IO TL.Text formatReport reports template = do let context "report" = return $ MuList $ map inner reports context "include" = return $ MuLambdaM $ includeFile [templateDir]@@ -153,13 +155,13 @@ -- \"@/etc/passwd@\". includeFile :: (MonadIO m) => [FilePath] -- ^ Directories to search.- -> B.ByteString -- ^ Name of the file to search for.- -> m B.ByteString-{-# SPECIALIZE includeFile :: [FilePath] -> B.ByteString -> IO B.ByteString #-}-includeFile searchPath name = liftIO $ foldr go (return B.empty) searchPath+ -> T.Text -- ^ Name of the file to search for.+ -> m T.Text+{-# SPECIALIZE includeFile :: [FilePath] -> T.Text -> IO T.Text #-}+includeFile searchPath name = liftIO $ foldr go (return T.empty) searchPath where go dir next = do let path = dir </> H.decodeStr name- B.readFile path `E.catch` \(_::IOException) -> next+ T.readFile path `E.catch` \(_::IOException) -> next -- | A problem arose with a template. data TemplateException =@@ -177,15 +179,15 @@ -- not be found, or an 'IOException' if no template could be loaded. loadTemplate :: [FilePath] -- ^ Search path. -> FilePath -- ^ Name of template file.- -> IO B.ByteString+ -> IO T.Text loadTemplate paths name- | any isPathSeparator name = B.readFile name+ | any isPathSeparator name = T.readFile name | otherwise = go Nothing paths where go me (p:ps) = do let cur = p </> name x <- doesFileExist cur if x- then B.readFile cur `E.catch` \e -> go (me `mplus` Just e) ps+ then T.readFile cur `E.catch` \e -> go (me `mplus` Just e) ps else go me ps go (Just e) _ = throwIO (e::IOException) go _ _ = throwIO . TemplateNotFound $ name
criterion.cabal view
@@ -1,5 +1,5 @@ name: criterion-version: 0.8.0.1+version: 0.8.0.2 synopsis: Robust, reliable performance measurement and analysis license: BSD3 license-file: LICENSE@@ -65,11 +65,12 @@ directory, filepath, Glob >= 0.7.2,- hastache >= 0.5.0,+ hastache >= 0.6.0, mtl >= 2, mwc-random >= 0.8.0.3, parsec >= 3.1.0, statistics >= 0.10.4.0 && < 0.11.0.0,+ text >= 0.11, time, transformers, vector >= 0.7.1,