ruby-changes:53649
From: samuel <ko1@a...>
Date: Tue, 20 Nov 2018 21:42:43 +0900 (JST)
Subject: [ruby-changes:53649] samuel:r65859 (trunk): Rename fiber chain benchmark.
samuel 2018-11-20 19:17:08 +0900 (Tue, 20 Nov 2018) New Revision: 65859 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65859 Log: Rename fiber chain benchmark. Added files: trunk/benchmark/fiber_chain.rb Removed files: trunk/benchmark/vm2_fiber_chain.rb Index: benchmark/vm2_fiber_chain.rb =================================================================== --- benchmark/vm2_fiber_chain.rb (revision 65858) +++ benchmark/vm2_fiber_chain.rb (nonexistent) @@ -1,40 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/vm2_fiber_chain.rb#L0 -# Check performance of fiber creation and transfer. - -def make_link(previous) - Fiber.new do - while message = previous.resume - Fiber.yield(message) - end - end -end - -def make_chain(length, &block) - chain = Fiber.new(&block) - - (length - 1).times do - chain = make_link(chain) - end - - return chain -end - -def run_benchmark(length, repeats, message = :hello) - chain = nil - - chain = make_chain(length) do - while true - Fiber.yield(message) - end - end - - repeats.times do - abort "invalid result" unless chain.resume == message - end -end - -n = (ARGV[0] || 1000).to_i -m = (ARGV[1] || 1000).to_i - -5.times do - run_benchmark(n, m) -end Property changes on: benchmark/vm2_fiber_chain.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: benchmark/fiber_chain.rb =================================================================== --- benchmark/fiber_chain.rb (nonexistent) +++ benchmark/fiber_chain.rb (revision 65859) @@ -0,0 +1,40 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/fiber_chain.rb#L1 +# Check performance of fiber creation and transfer. + +def make_link(previous) + Fiber.new do + while message = previous.resume + Fiber.yield(message) + end + end +end + +def make_chain(length, &block) + chain = Fiber.new(&block) + + (length - 1).times do + chain = make_link(chain) + end + + return chain +end + +def run_benchmark(length, repeats, message = :hello) + chain = nil + + chain = make_chain(length) do + while true + Fiber.yield(message) + end + end + + repeats.times do + abort "invalid result" unless chain.resume == message + end +end + +n = (ARGV[0] || 1000).to_i +m = (ARGV[1] || 1000).to_i + +5.times do + run_benchmark(n, m) +end Property changes on: benchmark/fiber_chain.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/