ruby-changes:53622
From: samuel <ko1@a...>
Date: Tue, 20 Nov 2018 19:07:03 +0900 (JST)
Subject: [ruby-changes:53622] samuel:r65841 (trunk): Fix code climate cognitive complexity issue
samuel 2018-11-20 19:06:58 +0900 (Tue, 20 Nov 2018) New Revision: 65841 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65841 Log: Fix code climate cognitive complexity issue Modified files: trunk/benchmark/bm_vm2_fiber_chain.rb Index: benchmark/bm_vm2_fiber_chain.rb =================================================================== --- benchmark/bm_vm2_fiber_chain.rb (revision 65840) +++ benchmark/bm_vm2_fiber_chain.rb (revision 65841) @@ -10,19 +10,25 @@ def make_link(previous) https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm2_fiber_chain.rb#L10 end end +def make_chain + chain = Fiber.new do + while true + Fiber.yield(message) + end + end + + (fibers - 1).times do + chain = make_link(chain) + end + + return chain +end + def run_benchmark(fibers, repeats, message = :hello) chain = nil time = Benchmark.realtime do - chain = Fiber.new do - while true - Fiber.yield(message) - end - end - - (fibers - 1).times do - chain = make_link(chain) - end + chain = make_chain end puts "Creating #{fibers} fibers took #{time}..." -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/