From c89ac91f3a9bab901417d5157a8d3ccbc8629df2 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 24 Sep 2014 10:43:49 +0200 Subject: [PATCH] Benchmark for lexing HTML void elements. --- .../xml/lexer/html_void_element_bench.rb | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 benchmark/xml/lexer/html_void_element_bench.rb diff --git a/benchmark/xml/lexer/html_void_element_bench.rb b/benchmark/xml/lexer/html_void_element_bench.rb new file mode 100644 index 0000000..10293c4 --- /dev/null +++ b/benchmark/xml/lexer/html_void_element_bench.rb @@ -0,0 +1,23 @@ +require_relative '../../benchmark_helper' + +content = '' +max_size = 5 * 1024 * 1024 + +while content.bytesize <= max_size + content << "
" +end + +html = "#{content}" +html_caps = "#{content.upcase}" + +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