Removed the XPath::Evaluator class
This commit is contained in:
parent
e4919d7c31
commit
31a574e7f8
|
@ -28,12 +28,13 @@ require 'profile' if ENV['PROFILE']
|
|||
thread_count.times.each do
|
||||
threads << Thread.new do
|
||||
oga_doc = documents.pop
|
||||
evaluator = Oga::XPath::Evaluator.new(oga_doc)
|
||||
compiler = Oga::XPath::Compiler.new
|
||||
block = compiler.compile(xpath_ast)
|
||||
|
||||
sample_size.times do
|
||||
break if stop
|
||||
|
||||
output << Benchmark.measure { evaluator.evaluate_ast(xpath_ast) }
|
||||
output << Benchmark.measure { block.call(oga_doc) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
require_relative '../../benchmark_helper'
|
||||
|
||||
xml_node = Oga::XML::Element.new(:name => 'foo')
|
||||
|
||||
name_only = AST::Node.new(:test, [nil, 'foo'])
|
||||
name_star = AST::Node.new(:test, [nil, '*'])
|
||||
name_ns_star = AST::Node.new(:test, ['*', 'foo'])
|
||||
name_ns = AST::Node.new(:test, ['bar', 'foo'])
|
||||
|
||||
evaluator = Oga::XPath::Evaluator.new(xml_node)
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'name only' do
|
||||
evaluator.node_matches?(xml_node, name_only)
|
||||
end
|
||||
|
||||
bench.report 'name wildcard' do
|
||||
evaluator.node_matches?(xml_node, name_star)
|
||||
end
|
||||
|
||||
bench.report 'name + namespace' do
|
||||
evaluator.node_matches?(xml_node, name_ns)
|
||||
end
|
||||
|
||||
bench.report 'namespace wildcard' do
|
||||
evaluator.node_matches?(xml_node, name_ns_star)
|
||||
end
|
||||
|
||||
bench.compare!
|
||||
end
|
|
@ -14,9 +14,6 @@ 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
|
||||
|
@ -31,12 +28,6 @@ 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
|
||||
|
|
|
@ -55,7 +55,6 @@ require 'oga/ruby/generator'
|
|||
|
||||
require 'oga/xpath/lexer'
|
||||
require 'oga/xpath/parser'
|
||||
require 'oga/xpath/evaluator'
|
||||
require 'oga/xpath/compiler'
|
||||
require 'oga/xpath/conversion'
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ module Oga
|
|||
#
|
||||
# @param [String] expression The XPath expression to run.
|
||||
# @param [Hash] variables Variables to bind.
|
||||
# @see [Oga::XPath::Evaluator#initialize]
|
||||
#
|
||||
def xpath(expression, variables = {})
|
||||
ast = XPath::Parser.parse_with_cache(expression)
|
||||
|
@ -35,7 +34,6 @@ module Oga
|
|||
# Evaluates the given CSS expression.
|
||||
#
|
||||
# @param [String] expression The CSS expression to run.
|
||||
# @see [Oga::XPath::Evaluator#initialize]
|
||||
#
|
||||
def css(expression)
|
||||
ast = CSS::Parser.parse_with_cache(expression)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue