summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorscoder <none@none>2006-10-27 08:52:09 +0200
committerscoder <none@none>2006-10-27 08:52:09 +0200
commit870b6f8473f4eb18492959044d143ecb86e6db0b (patch)
treec2fac8dba40b2ddc47833e9c3a949ee44f995d88 /benchmark
parentb9324fc2559c7d8befa6af872ec85f983b878073 (diff)
downloadpython-lxml-870b6f8473f4eb18492959044d143ecb86e6db0b.tar.gz
[svn r2005] fixes in bench_objectify.py, some more benchmarks
--HG-- branch : trunk
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bench_objectify.py50
1 files changed, 39 insertions, 11 deletions
diff --git a/benchmark/bench_objectify.py b/benchmark/bench_objectify.py
index 672f86ad..b3df645d 100644
--- a/benchmark/bench_objectify.py
+++ b/benchmark/bench_objectify.py
@@ -2,12 +2,6 @@ import sys, copy
from itertools import *
from StringIO import StringIO
-from lxml import etree, objectify
-
-parser = etree.XMLParser(remove_blank_text=True)
-lookup = etree.ElementNamespaceClassLookup(objectify.ObjectifyElementClassLookup())
-parser.setElementClassLookup(lookup)
-
import benchbase
from benchbase import with_attributes, with_text, onlylib, serialized
@@ -17,13 +11,24 @@ from benchbase import with_attributes, with_text, onlylib, serialized
class BenchMark(benchbase.BenchMarkBase):
def __init__(self, lib):
- benchbase.BenchMarkBase.__init__(self, lib, parser)
+ from lxml import etree, objectify
+ self.objectify = objectify
+ parser = etree.XMLParser(remove_blank_text=True)
+ lookup = objectify.ObjectifyElementClassLookup()
+ parser.setElementClassLookup(lookup)
+ super(BenchMark, self).__init__(etree, parser)
- def bench_attributes(self, root):
+ def bench_attribute(self, root):
"1 2 4"
for i in repeat(None, 3000):
root.zzzzz
+ def bench_attribute_cached(self, root):
+ "1 2 4"
+ cache = root.zzzzz
+ for i in repeat(None, 3000):
+ root.zzzzz
+
def bench_attributes_deep(self, root):
"1 2 4"
for i in repeat(None, 3000):
@@ -38,13 +43,13 @@ class BenchMark(benchbase.BenchMarkBase):
def bench_objectpath(self, root):
"1 2 4"
- path = objectify.ObjectPath(".zzzzz")
+ path = self.objectify.ObjectPath(".zzzzz")
for i in repeat(None, 3000):
path(root)
def bench_objectpath_deep(self, root):
"1 2 4"
- path = objectify.ObjectPath(".zzzzz.{cdefg}z00000")
+ path = self.objectify.ObjectPath(".zzzzz.{cdefg}z00000")
for i in repeat(None, 3000):
path(root)
@@ -52,9 +57,32 @@ class BenchMark(benchbase.BenchMarkBase):
"1 2 4"
cache1 = root.zzzzz
cache2 = cache1['{cdefg}z00000']
- path = objectify.ObjectPath(".zzzzz.{cdefg}z00000")
+ path = self.objectify.ObjectPath(".zzzzz.{cdefg}z00000")
for i in repeat(None, 3000):
path(root)
+ @with_text(text=True, utext=True, no_text=True)
+ def bench_annotate(self, root):
+ self.objectify.annotate(root)
+
+ def bench_descendantpaths(self, root):
+ root.descendantpaths()
+
+ @with_text(text=True)
+ def bench_type_inference(self, root):
+ "1 2 4"
+ el = root.aaaaa
+ for i in repeat(None, 1000):
+ el.getchildren()
+
+ @with_text(text=True)
+ def bench_type_inference_annotated(self, root):
+ "1 2 4"
+ el = root.aaaaa
+ self.objectify.annotate(el)
+ for i in repeat(None, 1000):
+ el.getchildren()
+
+
if __name__ == '__main__':
benchbase.main(BenchMark)