packages feed

xmlgen 0.4.0.1 → 0.4.0.2

raw patch · 3 files changed

+17/−30 lines, 3 filesdep −xml-typesdep ~hxt

Dependencies removed: xml-types

Dependency ranges changed: hxt

Files

src/Text/XML/Generator.hs view
@@ -49,18 +49,12 @@  ) where -{--TODO:--- documentation---}- import Prelude hiding (elem) import Control.Monad.Reader (Reader(..), ask, asks, runReader) import qualified Data.Map as Map import qualified Data.ByteString.Lazy as BSL import Data.Monoid hiding (mconcat)+import qualified Data.Monoid as M  import Blaze.ByteString.Builder import qualified Blaze.ByteString.Builder as Blaze@@ -284,7 +278,7 @@  -- |  Merges a list of attributes into a single piece of XML at the attribute level. xattrs :: [Xml Attr] -> Xml Attr-xattrs = foldr mappend noAttrs+xattrs = M.mconcat  -- | The empty attribute list. noAttrs :: Xml Attr@@ -389,7 +383,7 @@  -- |  Merges a list of elements into a single piece of XML at the element level. xelems :: [Xml Elem] -> Xml Elem-xelems = foldr mappend noElems+xelems = M.mconcat  -- | No elements at all. noElems :: Xml Elem
src/Text/XML/GeneratorBenchmarks.hs view
@@ -5,24 +5,18 @@  import Text.XML.Generator -gen1 :: Int -> IO ()-gen1 numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)-      where doc = xelem "root" $ xelems $ map (\s -> xelem "foo" (xattr "key" s, xtext s)) (map (\i -> T.pack (show i) :: T.Text) [1..numberOfElems])--gen2 :: Int -> IO ()-gen2 numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)-      where doc = xelem "root" $ foldr (<>) xempty $ map (\s -> xelem "foo" (xattr "key" s, xtext s)) (map (\i -> T.pack (show i) :: T.Text) [1..numberOfElems])+benchElems :: Int -> IO ()+benchElems numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)+      where doc = xelem "root" $ xelems $ map (\s -> xelem "foo" (xattr "key" s, xtext s)) (map (\i -> T.pack (show i)) [1..numberOfElems]) -gen3 :: Int -> IO ()-gen3 numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)-      where doc = xelem "root" $ xattrs $ map (\s -> xattr "key" s) (map (\i -> T.pack (show i) :: T.Text) [1..numberOfElems])+benchAttrs :: Int -> IO ()+benchAttrs numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)+      where doc = xelem "root" $ xattrs $ map (\s -> xattr ("key-" ++ s) (T.pack s)) (map (\i -> show i) [1..numberOfElems])  main =     do args <- getArgs        case args of-         "--standalone-1":s:[] -> gen1 (read s)-         "--standalone-2":s:[] -> gen2 (read s)-         "--standalone-3":s:[] -> gen3 (read s)-         _ -> defaultMain (concatMap (\i -> [bench ("gen1 " ++ show i) (gen1 i),-                                             bench ("gen2 " ++ show i) (gen2 i),-                                             bench ("gen3 " ++ show i) (gen3 i)]) [1000, 10000, 100000, 1000000])+         "--elems":s:[] -> benchElems (read s)+         "--attrs":s:[] -> benchAttrs (read s)+         _ -> defaultMain (concatMap (\i -> [bench (show i ++ " elems") (benchElems i),+                                             bench (show i ++ " attrs") (benchAttrs i)]) [1000, 10000, 100000, 1000000])
xmlgen.cabal view
@@ -1,5 +1,5 @@ Name:                xmlgen-Version:             0.4.0.1+Version:             0.4.0.2 Synopsis:            Fast XML generation library Description:         Library for high-performance XML generation. License:             BSD3@@ -19,8 +19,7 @@   Hs-Source-Dirs:    src   Build-Depends:     base >= 4.2 && < 4.4, blaze-builder == 0.3.*,                      bytestring == 0.9.*, containers >= 0.3 && < 0.5,-                     monads-tf == 0.1.*, text >= 0.10 && < 0.12,-                     xml-types == 0.3.*+                     monads-tf == 0.1.*, text >= 0.10 && < 0.12   Ghc-Prof-Options: -auto-all -caf-all  Flag tests@@ -29,7 +28,7 @@  Executable tests   If flag(tests)-    Build-Depends: HTF == 0.7.*, MissingH == 1.1.*, hxt == 9.0.*,+    Build-Depends: HTF == 0.7.*, MissingH == 1.1.*, hxt == 9.1.*,                    filepath == 1.2.*, unix == 2.4.*, process == 1.0.*   Else     Buildable: False@@ -46,6 +45,6 @@   Else     Buildable: False   Hs-Source-Dirs: src-  Ghc-Options: -O2+  Ghc-Options: -O2 -rtsopts   Ghc-Prof-Options: -auto-all -caf-all   Main-Is:        Text/XML/GeneratorBenchmarks.hs