Benchmark for measuring average lexing times.
This commit is contained in:
parent
f607cf50dc
commit
20f2f256f6
|
@ -0,0 +1,22 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
|
||||
xml = File.read(File.expand_path('../../fixtures/big.xml', __FILE__))
|
||||
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"
|
Loading…
Reference in New Issue