oga/benchmark/lexer/line_rate.rb

18 lines
338 B
Ruby
Raw Normal View History

2014-05-01 11:08:44 +00:00
require_relative '../benchmark_helper'
2014-05-01 11:08:44 +00:00
xml = read_big_xml
lines = xml.lines.count
lexer = Oga::XML::Lexer.new(xml)
timings = Benchmark.bm(20) do |bench|
bench.report("#{lines} lines") do
lexer.advance { |_| }
lexer.reset
end
end
time = timings[0].real
rate = lines / time
puts
puts "Lines/second: #{rate.round(3)}"