diff options
| author | scoder <none@none> | 2008-03-05 22:17:55 +0100 |
|---|---|---|
| committer | scoder <none@none> | 2008-03-05 22:17:55 +0100 |
| commit | cd2012d26546766e5ee3f4ef25a7e918499fb0a9 (patch) | |
| tree | 7dab69af6df756ed76927f6a0263f25b8da4926b /benchmark | |
| parent | edf8fa09b2e586f74c62f74097e5a82e14aefa36 (diff) | |
| download | python-lxml-cd2012d26546766e5ee3f4ef25a7e918499fb0a9.tar.gz | |
[svn r3400] r3730@delle: sbehnel | 2008-03-04 22:44:06 +0100
rewrite of 'text' serialiser: fix default encoding, faster .tail adding and 'unicode' encoding
--HG--
branch : trunk
Diffstat (limited to 'benchmark')
| -rw-r--r-- | benchmark/bench_etree.py | 29 | ||||
| -rw-r--r-- | benchmark/benchbase.py | 11 |
2 files changed, 35 insertions, 5 deletions
diff --git a/benchmark/bench_etree.py b/benchmark/bench_etree.py index 24a2851c..6397ea46 100644 --- a/benchmark/bench_etree.py +++ b/benchmark/bench_etree.py @@ -34,6 +34,35 @@ class BenchMark(benchbase.BenchMarkBase): for i in range(1000): child = root[pos] + @with_attributes(False) + @with_text(text=True) + @onlylib('lxe', 'ET') + def bench_tostring_text_ascii(self, root): + self.etree.tostring(root, method="text") + + @with_attributes(False) + @with_text(text=True, utext=True) + @onlylib('lxe') + def bench_tostring_text_utf16(self, root): + self.etree.tostring(root, method="text", encoding='UTF-16') + + @with_attributes(False) + @with_text(text=True, utext=True) + @onlylib('lxe', 'ET') + @children + def bench_tostring_text_utf8_with_tail(self, children): + for child in children: + self.etree.tostring(child, method="text", + encoding='UTF-8', with_tail=True) + + @with_attributes(False) + @with_text(text=True, utext=True) + @onlylib('lxe') + @children + def bench_tostring_text_unicode(self, children): + for child in children: + self.etree.tostring(child, method="text", encoding=unicode) + @with_attributes(True, False) @with_text(text=True, utext=True) def bench_tostring_utf8(self, root): diff --git a/benchmark/benchbase.py b/benchmark/benchbase.py index 5d995c9d..d9e7735a 100644 --- a/benchmark/benchbase.py +++ b/benchmark/benchbase.py @@ -200,7 +200,7 @@ class BenchMarkBase(object): el.text = text for ch2 in atoz: for i in range(20 * TREE_FACTOR): - SubElement(el, "{cdefg}%s%05d" % (ch2, i)) + SubElement(el, "{cdefg}%s%05d" % (ch2, i)).tail = text t = current_time() - t return (root, t) @@ -216,7 +216,7 @@ class BenchMarkBase(object): el = SubElement(root, "{abc}"+ch1*5, attributes) el.text = text for ch2 in atoz: - SubElement(el, "{cdefg}%s%05d" % (ch2, i)) + SubElement(el, "{cdefg}%s%05d" % (ch2, i)).tail = text t = current_time() - t return (root, t) @@ -231,8 +231,9 @@ class BenchMarkBase(object): tag_no = count().next children = [ SubElement(c, "{cdefg}a%05d" % i, attributes) for i,c in enumerate(chain(children, children, children)) ] - for child in root: + for child in children: child.text = text + child.tail = text t = current_time() - t return (root, t) @@ -246,8 +247,8 @@ class BenchMarkBase(object): for ch1 in self.atoz: el = SubElement(root, "{abc}"+ch1*5, attributes) el.text = text - SubElement(el, "{cdefg}a00001", attributes) - SubElement(el, "{cdefg}z00000", attributes) + SubElement(el, "{cdefg}a00001", attributes).tail = text + SubElement(el, "{cdefg}z00000", attributes).tail = text t = current_time() - t return (root, t) |
