diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-06-02 13:48:47 +1200 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-07-12 11:56:51 +1200 |
commit | 012e954b472d2e47b03647ac0c8f745416d7db58 (patch) | |
tree | f2f3f0f17de96445c361c358590dbac5a6db969d /benchmark/fiber_chain.yml | |
parent | 8745fa2ff0fbff67031bdecfdeea684b15515a2c (diff) | |
download | ruby-012e954b472d2e47b03647ac0c8f745416d7db58.tar.gz |
Improved fiber benchmarks. Increase number of iterations.
Diffstat (limited to 'benchmark/fiber_chain.yml')
-rwxr-xr-x | benchmark/fiber_chain.yml | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/benchmark/fiber_chain.yml b/benchmark/fiber_chain.yml new file mode 100755 index 0000000000..e526551da4 --- /dev/null +++ b/benchmark/fiber_chain.yml @@ -0,0 +1,36 @@ +prelude: | + def make_link(previous) + Fiber.new do + while message = previous.resume + Fiber.yield(message) + end + end + end + + def make_chain(length = 1000, &block) + chain = Fiber.new(&block) + + (length - 1).times do + chain = make_link(chain) + end + + return chain + end + + message = "Hello World!" + + chain = make_chain do + while true + Fiber.yield(message) + end + end +benchmark: + make_chain: | + make_chain(100) do + while true + Fiber.yield(message) + end + end + resume_chain: | + chain.resume +loop_count: 5000 |