Benchmark for lexing HTML void elements.

This commit is contained in:
Yorick Peterse 2014-09-24 10:43:49 +02:00
parent d004bc7233
commit c89ac91f3a
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
require_relative '../../benchmark_helper'
content = ''
max_size = 5 * 1024 * 1024
while content.bytesize <= max_size
content << "<br>"
end
html = "<body>#{content}</body>"
html_caps = "<body>#{content.upcase}</body>"
Benchmark.ips do |bench|
bench.report 'void elements' do
Oga::XML::Lexer.new(html, :html => true).advance { }
end
bench.report 'void elements caps' do
Oga::XML::Lexer.new(html_caps, :html => true).advance { }
end
bench.compare!
end