Benchmark for measuring CDATA lexing.

This commit is contained in:
Yorick Peterse 2014-03-21 16:59:44 +01:00
parent 55f116124c
commit 2852afce9b
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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