2014-03-21 15:59:44 +00:00
|
|
|
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}]]>"
|
2014-03-25 08:34:38 +00:00
|
|
|
lexer = Oga::XML::Lexer.new
|
2014-03-21 15:59:44 +00:00
|
|
|
|
|
|
|
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
|