diff options
| author | scoder <none@none> | 2006-10-27 08:54:28 +0200 |
|---|---|---|
| committer | scoder <none@none> | 2006-10-27 08:54:28 +0200 |
| commit | 2c5873e51f8d1a8e3c4a42f59ebb43c5e36980ad (patch) | |
| tree | 8cc0bf460df20cdd7990e99b341bf6eb8b1d5e79 /benchmark/bench_objectify.py | |
| parent | 870b6f8473f4eb18492959044d143ecb86e6db0b (diff) | |
| download | python-lxml-2c5873e51f8d1a8e3c4a42f59ebb43c5e36980ad.tar.gz | |
[svn r2006] reverted
--HG--
branch : trunk
Diffstat (limited to 'benchmark/bench_objectify.py')
| -rw-r--r-- | benchmark/bench_objectify.py | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/benchmark/bench_objectify.py b/benchmark/bench_objectify.py index b3df645d..672f86ad 100644 --- a/benchmark/bench_objectify.py +++ b/benchmark/bench_objectify.py @@ -2,6 +2,12 @@ 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 @@ -11,24 +17,13 @@ from benchbase import with_attributes, with_text, onlylib, serialized class BenchMark(benchbase.BenchMarkBase): def __init__(self, lib): - 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) + benchbase.BenchMarkBase.__init__(self, lib, parser) - def bench_attribute(self, root): + def bench_attributes(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): @@ -43,13 +38,13 @@ class BenchMark(benchbase.BenchMarkBase): def bench_objectpath(self, root): "1 2 4" - path = self.objectify.ObjectPath(".zzzzz") + path = objectify.ObjectPath(".zzzzz") for i in repeat(None, 3000): path(root) def bench_objectpath_deep(self, root): "1 2 4" - path = self.objectify.ObjectPath(".zzzzz.{cdefg}z00000") + path = objectify.ObjectPath(".zzzzz.{cdefg}z00000") for i in repeat(None, 3000): path(root) @@ -57,32 +52,9 @@ class BenchMark(benchbase.BenchMarkBase): "1 2 4" cache1 = root.zzzzz cache2 = cache1['{cdefg}z00000'] - path = self.objectify.ObjectPath(".zzzzz.{cdefg}z00000") + path = 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) |
