Benchmark for measuring CDATA lexing.
This commit is contained in:
parent
55f116124c
commit
2852afce9b
|
@ -0,0 +1,22 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
|
||||
string = 'Hello, how are you doing today?'
|
||||
small = "<![CDATA[#{string}]]>"
|
||||
medium = "<![CDATA[#{string * 1_000}]]>"
|
||||
large = "<![CDATA[#{string * 10_000}]]>"
|
||||
lexer = Oga::Lexer.new
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'CDATA with a small body' do
|
||||
lexer.lex(small)
|
||||
end
|
||||
|
||||
bench.report 'CDATA with a medium body' do
|
||||
lexer.lex(medium)
|
||||
end
|
||||
|
||||
bench.report 'CDATA with a large body' do
|
||||
lexer.lex(large)
|
||||
end
|
||||
end
|
|
@ -24,4 +24,5 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency 'yard'
|
||||
s.add_development_dependency 'simplecov'
|
||||
s.add_development_dependency 'kramdown'
|
||||
s.add_development_dependency 'benchmark-ips'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue