module BigBench module Benchmark class Looper attr_accessor :benchmark attr_accessor :loops def initialize(benchmark) @benchmark, @loops = benchmark, 0 @fragments = Fiber.new { @benchmark.fragments.cycle{ |fragment| Fiber.yield(fragment) } } end def loop! return unless @benchmark.is_running? @loops += 1 # Start next fragment fragment = next_fragment start = Time.now http = fragment.run! # Success http.callback do |http| fragment.track!(start, Time.now, http) loop! end # Error http.errback do |http| fragment.track!(start, Time.now, http) loop! end end def next_fragment @fragments.resume end end end end