Basic benchmarks for the Parser class.

This commit is contained in:
Yorick Peterse 2014-04-10 10:05:04 +02:00
parent 8ca7781842
commit 292a98d7f6
2 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -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