3件ヒット
[1-3件を表示]
(0.013秒)
別のキーワード
検索結果
先頭3件
-
Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] (54523.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... -
Benchmark
. # bmbm(width = 0) {|job| . . . } -> [Benchmark :: Tms] (36640.0) -
Benchmark::Job オブジェクトを生成して、それを引数として与えられたブロックを 実行します。
...
Benchmark::Job オブジェクトを生成して、それを引数として与えられたブロックを
実行します。
ベンチマークの結果は GC の影響によって歪められてしまうことがあります。
このメソッドは与えられたブロックを二度実行する......する
ことは保証されません。
@param width ラベルの幅を指定します。
//emlist[][ruby]{
require 'benchmark'
array = (1..1000000).map { rand }
Benchmark.bmbm do |x|
x.report("sort!") { array.dup.sort! }
x.report("sort") { array.dup.sort }
end
#=>
#
# Rehearsal --------... -
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (124.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::...