summaryrefslogtreecommitdiff
path: root/benchmark/bm_vm2_fiber_chain.rb
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/bm_vm2_fiber_chain.rb')
-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}..."