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>'
|
2014-03-25 08:34:38 +00:00
|
|
|
lexer = Oga::XML::Lexer.new
|
2014-03-21 16:45:23 +00:00
|
|
|
|
|
|
|
Benchmark.ips do |bench|
|
|
|
|
bench.report 'text only' do
|
|
|
|
lexer.lex(simple)
|
|
|
|
end
|
|
|
|
|
|
|
|
bench.report 'text + attributes' do
|
|
|
|
lexer.lex(attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
bench.report 'text + children' do
|
|
|
|
lexer.lex(nested)
|
|
|
|
end
|
|
|
|
end
|