Benchmark Oga XPath evaluation without the parser.

This gives better insight in the performance of the evaluator itself.
This commit is contained in:
Yorick Peterse committed 2014-09-02 20:55:42 +02:00
1 parent 84d6ba96c2
commit d92133ef43
2 files changed
+22 -2

No files matched your search

@@ -14,6 +14,9 @@ rex_doc = REXML::Document.new(xml)
ox_exp = 'number/^Text'
xpath_exp = 'root/number/text()'
oga_ast = Oga::XPath::Parser.new(xpath_exp).parse
evaluator = Oga::XPath::Evaluator.new(oga_doc)
Benchmark.ips do |bench|
# Technically not XPath but it's the closest thing Ox provides.
bench.report 'Ox' do
@@ -28,6 +31,12 @@ Benchmark.ips do |bench|
oga_doc.xpath(xpath_exp)
end
# This is measured to see what the performance of the evaluator is _without_
# the overhead of the lexer/parser.
bench.report 'Oga cached' do
evaluator.evaluate_ast(oga_ast)
end
bench.report 'REXML' do
REXML::XPath.match(rex_doc, xpath_exp)
end