зеркало из https://github.com/github/ruby.git
Remove `Benchmark` times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3710dedc12
Коммит
20f1c6c185
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env ruby
|
# Check performance of fiber creation and transfer.
|
||||||
|
|
||||||
require 'benchmark'
|
|
||||||
|
|
||||||
def make_link(previous)
|
def make_link(previous)
|
||||||
Fiber.new do
|
Fiber.new do
|
||||||
|
@ -23,23 +21,15 @@ end
|
||||||
def run_benchmark(length, repeats, message = :hello)
|
def run_benchmark(length, repeats, message = :hello)
|
||||||
chain = nil
|
chain = nil
|
||||||
|
|
||||||
time = Benchmark.realtime do
|
chain = make_chain(length) do
|
||||||
chain = make_chain(length) do
|
while true
|
||||||
while true
|
Fiber.yield(message)
|
||||||
Fiber.yield(message)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Creating #{fibers} fibers took #{time}..."
|
repeats.times do
|
||||||
|
abort "invalid result" unless chain.resume == message
|
||||||
time = Benchmark.realtime do
|
|
||||||
repeats.times do
|
|
||||||
abort "invalid result" unless chain.resume == message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Passing #{repeats} messages took #{time}..."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
n = (ARGV[0] || 1000).to_i
|
n = (ARGV[0] || 1000).to_i
|
||||||
|
|
Загрузка…
Ссылка в новой задаче