Permalink
Browse files

support for raw content, Data.Text, Data.ByteString + benchmarks

migrated from darcs:

Sat Jan  8 20:10:50 CET 2011  Stefan Wehr <wehr@factisresearch.com>
  * support for raw content, Data.Text, Data.ByteString + benchmarks
  • Loading branch information...
1 parent 6c57561 commit 685bc4934779bc9018cd5c57b9ab072ce1e50bf9 @skogsbaer committed Jan 16, 2011
Showing with 35 additions and 0 deletions.
  1. +15 −0 src/Text/XML/GeneratorBenchmarks.hs
  2. +7 −0 test/1.xml
  3. +11 −0 test/2.xml
  4. +2 −0 test/3.xml
@@ -0,0 +1,15 @@
+import Criterion.Main
+import qualified Data.ByteString.Lazy as BSL
+import System.Environment
+
+import Text.XML.Generator
+
+gen :: Int -> IO ()
+gen numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)
+ where doc = xelem "root" $ xelems $ map (\s -> xelem "foo" (xattr "key" s, xtext s)) (map show [1..numberOfElems])
+
+main =
+ do args <- getArgs
+ case args of
+ "--standalone":s:[] -> gen (read s)
+ _ -> defaultMain (map (\i -> bench ("gen " ++ show i) (gen i)) [1000, 10000, 100000])
View
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<__foo:foo xmlns:__foo="urn:__foo" xmlns:_foo="urn:_foo" _foo:key="value" _foo:key2="value">
+ <foo:bar xmlns:foo="urn:foo" _foo:key="value">BAR</foo:bar>
+ <foo:bar xmlns:foo="urn:foo">
+ <___foo:spam xmlns:___foo="urn:bar"><egg/>this is spam!</___foo:spam>
+ </foo:bar>
+</__foo:foo>
View
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<foo key="value" key2="value2">
+ <bar/>
+ <spam key="value"/>
+ <egg>ham</egg>
+ <foo:bar xmlns:foo="http://www.example.com"/>
+ <foo:spam xmlns:foo="http://www.example.com" foo:key="value"/>
+ <foo:egg xmlns:foo="http://www.example.com">
+ <ham/>
+ </foo:egg>
+</foo>
View
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<foo key="val&quot;'&amp;&lt;&gt;ue">&lt;&amp;;'</foo>

0 comments on commit 685bc49

Please sign in to comment.