2件ヒット
[1-2件を表示]
(0.109秒)
検索結果
先頭2件
-
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (1243.0) -
Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
...
Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
基本的には以下のように使います。
ブロックが Benchmark::Tms オブジェクトの配列を返した場合は、
それらの数値も追加の行に表示......tstr フォーマット文字列を指定します。
この引数を省略すると Benchmark::FORMAT が使用されます。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
=== フォーマット文字列
フ......。Benchmark::Tms#utime
: %y
system CPU time で置き換えられます(Mnemonic: y of "s*y*stem")。Benchmark::Tms#stime
: %U
子プロセスの user CPU time で置き換えられます。Benchmark::Tms#cutime
: %Y
子プロセスの system CPU time で置き換えられます。Benchmark::... -
Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] (1243.0) -
Benchmark.#benchmark メソッドの引数を簡略化したものです。
...
Benchmark.#benchmark メソッドの引数を簡略化したものです。
Benchmark.#benchmark メソッドと同様に働きます。
@param label_width ラベルの幅を指定します。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定し......ます。
//emlist[][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm do |x|
x.report { for i in 1..n; a = "1"; end }
x.report { n.times do ; a = "1"; end }
x.report { 1.upto(n) do ; a = "1"; end }
end
#=>
#
# user system total real
# 1.033333 0.016667 1.016667 (......83333 ( 0.694605)
# 1.516667 0.000000 1.516667 ( 0.711077)
//}
以下のようにも書けます。
//emlist[][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm(7) do |x|
x.report("for:") { for i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("up...