ruby-changes:53623
From: samuel <ko1@a...>
Date: Tue, 20 Nov 2018 19:13:58 +0900 (JST)
Subject: [ruby-changes:53623] samuel:r65845 (trunk): Better benchmark name.
samuel 2018-11-20 19:13:51 +0900 (Tue, 20 Nov 2018) New Revision: 65845 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65845 Log: Better benchmark name. Added files: trunk/benchmark/vm2_fiber_chain.rb Removed files: trunk/benchmark/bm_vm2_fiber_chain.rb Index: benchmark/bm_vm2_fiber_chain.rb =================================================================== --- benchmark/bm_vm2_fiber_chain.rb (revision 65844) +++ benchmark/bm_vm2_fiber_chain.rb (nonexistent) @@ -1,50 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm2_fiber_chain.rb#L0 -#!/usr/bin/env ruby - -require 'benchmark' - -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 - - time = Benchmark.realtime do - chain = make_chain(length) do - while true - Fiber.yield(message) - end - end - end - - puts "Creating #{fibers} fibers took #{time}..." - - time = Benchmark.realtime do - repeats.times do - abort "invalid result" unless chain.resume == message - end - end - - puts "Passing #{repeats} messages took #{time}..." -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/bm_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/vm2_fiber_chain.rb =================================================================== --- benchmark/vm2_fiber_chain.rb (nonexistent) +++ benchmark/vm2_fiber_chain.rb (revision 65845) @@ -0,0 +1,50 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/vm2_fiber_chain.rb#L1 +#!/usr/bin/env ruby + +require 'benchmark' + +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 + + time = Benchmark.realtime do + chain = make_chain(length) do + while true + Fiber.yield(message) + end + end + end + + puts "Creating #{fibers} fibers took #{time}..." + + time = Benchmark.realtime do + repeats.times do + abort "invalid result" unless chain.resume == message + end + end + + puts "Passing #{repeats} messages took #{time}..." +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 ___________________________________________________________________ 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/