Simple benchmark for lexing elements.

This commit is contained in:
Yorick Peterse 2014-03-21 17:45:23 +01:00
parent 9fa694ad4f
commit d7a40ec470
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
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>'
lexer = Oga::Lexer.new
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