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}]]>"
|
small = "<![CDATA[#{string}]]>"
|
||||||
medium = "<![CDATA[#{string * 1_000}]]>"
|
medium = "<![CDATA[#{string * 1_000}]]>"
|
||||||
large = "<![CDATA[#{string * 10_000}]]>"
|
large = "<![CDATA[#{string * 10_000}]]>"
|
||||||
lexer = Oga::XML::Lexer.new
|
|
||||||
|
|
||||||
Benchmark.ips do |bench|
|
Benchmark.ips do |bench|
|
||||||
bench.report 'CDATA with a small body' do
|
bench.report 'CDATA with a small body' do
|
||||||
lexer.lex(small)
|
Oga::XML::Lexer.new(small).lex
|
||||||
end
|
end
|
||||||
|
|
||||||
bench.report 'CDATA with a medium body' do
|
bench.report 'CDATA with a medium body' do
|
||||||
lexer.lex(medium)
|
Oga::XML::Lexer.new(medium).lex
|
||||||
end
|
end
|
||||||
|
|
||||||
bench.report 'CDATA with a large body' do
|
bench.report 'CDATA with a large body' do
|
||||||
lexer.lex(large)
|
Oga::XML::Lexer.new(large).lex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,18 +4,17 @@ require 'benchmark/ips'
|
||||||
simple = '<p>Hello world</p>'
|
simple = '<p>Hello world</p>'
|
||||||
attributes = '<p class="foo">Hello world</p>'
|
attributes = '<p class="foo">Hello world</p>'
|
||||||
nested = '<p>Hello<strong>world</strong></p>'
|
nested = '<p>Hello<strong>world</strong></p>'
|
||||||
lexer = Oga::XML::Lexer.new
|
|
||||||
|
|
||||||
Benchmark.ips do |bench|
|
Benchmark.ips do |bench|
|
||||||
bench.report 'text only' do
|
bench.report 'text only' do
|
||||||
lexer.lex(simple)
|
Oga::XML::Lexer.new(simple).lex
|
||||||
end
|
end
|
||||||
|
|
||||||
bench.report 'text + attributes' do
|
bench.report 'text + attributes' do
|
||||||
lexer.lex(attributes)
|
Oga::XML::Lexer.new(attributes).lex
|
||||||
end
|
end
|
||||||
|
|
||||||
bench.report 'text + children' do
|
bench.report 'text + children' do
|
||||||
lexer.lex(nested)
|
Oga::XML::Lexer.new(nested).lex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
require_relative '../../lib/oga'
|
require_relative '../../lib/oga'
|
||||||
require 'benchmark/ips'
|
require 'benchmark/ips'
|
||||||
|
|
||||||
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
||||||
lexer = Oga::XML::Lexer.new(:html => true)
|
|
||||||
|
|
||||||
Benchmark.ips do |bench|
|
Benchmark.ips do |bench|
|
||||||
bench.report 'lex HTML' do
|
bench.report 'lex HTML' do
|
||||||
lexer.lex(html)
|
Oga::XML::Lexer.new(html, :html => true).lex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
require_relative '../../lib/oga'
|
require_relative '../../lib/oga'
|
||||||
require 'benchmark'
|
require 'benchmark'
|
||||||
|
|
||||||
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__))
|
||||||
lexer = Oga::XML::Lexer.new(:html => true)
|
|
||||||
|
|
||||||
Benchmark.bmbm(20) do |bench|
|
Benchmark.bmbm(20) do |bench|
|
||||||
bench.report 'lex HTML' do
|
bench.report 'lex HTML' do
|
||||||
lexer.lex(html)
|
Oga::XML::Lexer.new(html, :html => true).lex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue