diff --git a/benchmark/bm_vm2_fiber_chain.rb b/benchmark/bm_vm2_fiber_chain.rb index d4809572c4..eda12fb948 100755 --- a/benchmark/bm_vm2_fiber_chain.rb +++ b/benchmark/bm_vm2_fiber_chain.rb @@ -10,25 +10,25 @@ def make_link(previous) end end -def make_chain - chain = Fiber.new do - while true - Fiber.yield(message) - end - end - - (fibers - 1).times do +def make_chain(length, &block) + chain = Fiber.new(&block) + + (length - 1).times do chain = make_link(chain) end return chain end -def run_benchmark(fibers, repeats, message = :hello) +def run_benchmark(length, repeats, message = :hello) chain = nil time = Benchmark.realtime do - chain = make_chain + chain = make_chain(length) do + while true + Fiber.yield(message) + end + end end puts "Creating #{fibers} fibers took #{time}..."