Benchmark Oga XPath evaluation without the parser.
This gives better insight in the performance of the evaluator itself.
This commit is contained in:
1 parent
84d6ba96c2
commit
d92133ef43
2 files changed
+22
-2
No files matched your search
@@ -79,10 +79,21 @@ module Oga
|
||||
# evaluator.evaluate('//a')
|
||||
#
|
||||
# @param [String] string An XPath expression as a String.
|
||||
# @return [Oga::XML::Node]
|
||||
# @return [Mixed]
|
||||
#
|
||||
def evaluate(string)
|
||||
ast = Parser.new(string).parse
|
||||
ast = Parser.new(string).parse
|
||||
|
||||
return evaluate_ast(ast)
|
||||
end
|
||||
|
||||
##
|
||||
# Evaluates a pre-parsed XPath expression.
|
||||
#
|
||||
# @param [Oga::XPath::Node] ast_node
|
||||
# @return [Mixed]
|
||||
#
|
||||
def evaluate_ast(ast)
|
||||
context = XML::NodeSet.new([@document])
|
||||
|
||||
return process(ast, context)
|
||||
|
||||
Reference in new issue
Block a user