From 12ae8c0813cc66cc49fe9ce41b82074d60586329 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 20 Nov 2018 10:09:53 +0000 Subject: [PATCH] Fix broken benchmark git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- benchmark/bm_vm2_fiber_chain.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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}..."