Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 685bc4934779bc9018cd5c57b9ab072ce1e50bf9 1 parent 6c57561
Stefan Wehr authored January 16, 2011
15  src/Text/XML/GeneratorBenchmarks.hs
... ...
@@ -0,0 +1,15 @@
  1
+import Criterion.Main
  2
+import qualified Data.ByteString.Lazy as BSL
  3
+import System.Environment
  4
+
  5
+import Text.XML.Generator
  6
+
  7
+gen :: Int -> IO ()
  8
+gen numberOfElems = BSL.writeFile "/tmp/test.xml" (xrender doc)
  9
+      where doc = xelem "root" $ xelems $ map (\s -> xelem "foo" (xattr "key" s, xtext s)) (map show [1..numberOfElems])
  10
+
  11
+main =
  12
+    do args <- getArgs
  13
+       case args of
  14
+         "--standalone":s:[] -> gen (read s)
  15
+         _ -> defaultMain (map (\i -> bench ("gen " ++ show i) (gen i)) [1000, 10000, 100000])
7  test/1.xml
... ...
@@ -0,0 +1,7 @@
  1
+<?xml version="1.0"?>
  2
+<__foo:foo xmlns:__foo="urn:__foo" xmlns:_foo="urn:_foo" _foo:key="value" _foo:key2="value">
  3
+  <foo:bar xmlns:foo="urn:foo" _foo:key="value">BAR</foo:bar>
  4
+  <foo:bar xmlns:foo="urn:foo">
  5
+    <___foo:spam xmlns:___foo="urn:bar"><egg/>this is spam!</___foo:spam>
  6
+  </foo:bar>
  7
+</__foo:foo>
11  test/2.xml
... ...
@@ -0,0 +1,11 @@
  1
+<?xml version="1.0"?>
  2
+<foo key="value" key2="value2">
  3
+  <bar/>
  4
+  <spam key="value"/>
  5
+  <egg>ham</egg>
  6
+  <foo:bar xmlns:foo="http://www.example.com"/>
  7
+  <foo:spam xmlns:foo="http://www.example.com" foo:key="value"/>
  8
+  <foo:egg xmlns:foo="http://www.example.com">
  9
+    <ham/>
  10
+  </foo:egg>
  11
+</foo>
2  test/3.xml
... ...
@@ -0,0 +1,2 @@
  1
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2
+<foo key="val&quot;'&amp;&lt;&gt;ue">&lt;&amp;;'</foo>

0 notes on commit 685bc49

Please sign in to comment.
Something went wrong with that request. Please try again.