summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsamuel <samuel@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-20 10:06:58 +0000
committersamuel <samuel@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-20 10:06:58 +0000
commit995f6ee1026dd797ec3543ce0888a71d373330d4 (patch)
treedf9d221c083a9f8790ce50203a0b43bfec788bd6
parent4aa44a762e568f3664d6a1a989d44ec603a5e0e0 (diff)
Fix code climate cognitive complexity issue
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rwxr-xr-xbenchmark/bm_vm2_fiber_chain.rb24
1 files changed, 15 insertions, 9 deletions
diff --git a/benchmark/bm_vm2_fiber_chain.rb b/benchmark/bm_vm2_fiber_chain.rb
index 926eefb..715bd4b 100755
--- a/benchmark/bm_vm2_fiber_chain.rb
+++ b/benchmark/bm_vm2_fiber_chain.rb
@@ -10,19 +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
+ 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}..."