Basic benchmarks for the Parser class.
This commit is contained in:
parent
8ca7781842
commit
292a98d7f6
benchmark/parser
|
@ -0,0 +1,20 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
|
||||
simple = '<p>Hello world</p>'
|
||||
attributes = '<p class="foo">Hello world</p>'
|
||||
nested = '<p>Hello<strong>world</strong></p>'
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'text only' do
|
||||
Oga::XML::Parser.new(simple).parse
|
||||
end
|
||||
|
||||
bench.report 'text + attributes' do
|
||||
Oga::XML::Parser.new(attributes).parse
|
||||
end
|
||||
|
||||
bench.report 'text + children' do
|
||||
Oga::XML::Parser.new(nested).parse
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
|
||||
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'parse HTML' do
|
||||
Oga::HTML::Parser.new(html).parse
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue