oga/benchmark/lexer/big_xml_average.rb

22 lines
390 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
amount = 10
timings = []
amount.times do |i|
timing = Benchmark.measure do
Oga::XML::Lexer.new(xml).advance { }
end
puts "Iteration #{i + 1}: #{timing.real.round(3)}"
timings << timing.real
end
average = timings.inject(:+) / amount
puts
puts "Iterations: #{amount}"
puts "Average: #{average.round(3)} sec"