зеркало из https://github.com/github/ruby.git
Fix code climate cognitive complexity issue
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
4aa44a762e
Коммит
995f6ee102
|
@ -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}..."
|
||||
|
|
Загрузка…
Ссылка в новой задаче