Updated the lexer benchmarks.
These had to be updated for the API changes of Oga::XML::Lexer.
This commit is contained in:
parent
8237d5791d
commit
8ca7781842
|
@ -5,18 +5,17 @@ string = 'Hello, how are you doing today?'
|
|||
small = "<![CDATA[#{string}]]>"
|
||||
medium = "<![CDATA[#{string * 1_000}]]>"
|
||||
large = "<![CDATA[#{string * 10_000}]]>"
|
||||
lexer = Oga::XML::Lexer.new
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'CDATA with a small body' do
|
||||
lexer.lex(small)
|
||||
Oga::XML::Lexer.new(small).lex
|
||||
end
|
||||
|
||||
bench.report 'CDATA with a medium body' do
|
||||
lexer.lex(medium)
|
||||
Oga::XML::Lexer.new(medium).lex
|
||||
end
|
||||
|
||||
bench.report 'CDATA with a large body' do
|
||||
lexer.lex(large)
|
||||
Oga::XML::Lexer.new(large).lex
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,18 +4,17 @@ require 'benchmark/ips'
|
|||
simple = '<p>Hello world</p>'
|
||||
attributes = '<p class="foo">Hello world</p>'
|
||||
nested = '<p>Hello<strong>world</strong></p>'
|
||||
lexer = Oga::XML::Lexer.new
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'text only' do
|
||||
lexer.lex(simple)
|
||||
Oga::XML::Lexer.new(simple).lex
|
||||
end
|
||||
|
||||
bench.report 'text + attributes' do
|
||||
lexer.lex(attributes)
|
||||
Oga::XML::Lexer.new(attributes).lex
|
||||
end
|
||||
|
||||
bench.report 'text + children' do
|
||||
lexer.lex(nested)
|
||||
Oga::XML::Lexer.new(nested).lex
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,9 @@ require_relative '../../lib/oga'
|
|||
require 'benchmark/ips'
|
||||
|
||||
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
||||
lexer = Oga::XML::Lexer.new(:html => true)
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'lex HTML' do
|
||||
lexer.lex(html)
|
||||
Oga::XML::Lexer.new(html, :html => true).lex
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,9 @@ require_relative '../../lib/oga'
|
|||
require 'benchmark'
|
||||
|
||||
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
||||
lexer = Oga::XML::Lexer.new(:html => true)
|
||||
|
||||
Benchmark.bmbm(20) do |bench|
|
||||
bench.report 'lex HTML' do
|
||||
lexer.lex(html)
|
||||
Oga::XML::Lexer.new(html, :html => true).lex
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue