Ruby 初心者スレッド Part 21 at TECH
[2ch|▼Menu]
343:デフォルトの名無しさん
08/08/29 23:42:39
require 'open-uri'
require 'benchmark'
uris = %w(URLリンク(www.yahoo.co.jp) URLリンク(pc11.2ch.net) URLリンク(www.yahoo.com)).map{|e| URI(e)}

Benchmark.bm(2) do |x|
x.report{
uris.each do |uri|
uri.read
end
}
end
sleep 2
Benchmark.bm(2) do |x|
x.report{
threads = Array.new
uris.each do |uri|
threads.push(Thread.new { uri.read })
end
threads.each{|thread| thread.join}
}
end

# 結果
user system total real
1.150000 0.080000 1.230000 ( 2.655373)
user system total real
1.210000 0.060000 1.270000 ( 1.583636)


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5494日前に更新/211 KB
担当:undef