summaryrefslogtreecommitdiff
path: root/benchmark/bench_xpath.py
diff options
context:
space:
mode:
authorscoder <none@none>2007-03-16 20:26:13 +0100
committerscoder <none@none>2007-03-16 20:26:13 +0100
commit30c9b0357ef6345ae200f76513f931eb46c7a38b (patch)
tree8c8e3281a7fd701e12810395303c6e6faf7b497d /benchmark/bench_xpath.py
parent01e76044d30e1be0272b6afc728078bf2afa0773 (diff)
downloadpython-lxml-30c9b0357ef6345ae200f76513f931eb46c7a38b.tar.gz
[svn r2199] benchmark both the old and the new way of using extension functions
--HG-- branch : trunk
Diffstat (limited to 'benchmark/bench_xpath.py')
-rw-r--r--benchmark/bench_xpath.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/benchmark/bench_xpath.py b/benchmark/bench_xpath.py
index 8e971679..fc4c0419 100644
--- a/benchmark/bench_xpath.py
+++ b/benchmark/bench_xpath.py
@@ -34,7 +34,7 @@ class XPathBenchMark(benchbase.BenchMarkBase):
child.xpath("./*[0]")
@onlylib('lxe')
- def bench_xpath_extensions_old(self, root):
+ def bench_xpath_old_extensions(self, root):
def return_child(_, element):
if element:
return element[0]
@@ -45,5 +45,21 @@ class XPathBenchMark(benchbase.BenchMarkBase):
for child in root:
xpath(child)
+ @onlylib('lxe')
+ def bench_xpath_extensions(self, root):
+ def return_child(_, element):
+ if element:
+ return element[0]
+ else:
+ return ()
+ self.etree.FunctionNamespace("test")["t"] = return_child
+
+ try:
+ xpath = self.etree.XPath("test:t(.)", {"test":"test"})
+ for child in root:
+ xpath(child)
+ finally:
+ del self.etree.FunctionNamespace("test")["t"]
+
if __name__ == '__main__':
benchbase.main(XPathBenchMark)