oga/benchmark/lexer/bench_element.rb

21 lines
454 B
Ruby
Raw Normal View History

2014-03-21 16:45:23 +00:00
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::Lexer.new(simple).lex
2014-03-21 16:45:23 +00:00
end
bench.report 'text + attributes' do
Oga::XML::Lexer.new(attributes).lex
2014-03-21 16:45:23 +00:00
end
bench.report 'text + children' do
Oga::XML::Lexer.new(nested).lex
2014-03-21 16:45:23 +00:00
end
end