11件ヒット
[1-11件を表示]
(0.011秒)
検索結果
先頭5件
-
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (61.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] (61.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
:: Tms # cstime -> Float (55.0) -
子プロセスの System CPU time
子プロセスの System CPU time -
Benchmark
:: Tms # stime -> Float (55.0) -
System CPU time
System CPU time -
Benchmark
:: FORMAT -> String (43.0) -
Benchmark.#benchmark の第三引数のデフォルト値。
...
Benchmark.#benchmark の第三引数のデフォルト値。
: %u
user CPU time で置き換えられます。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::Tms#cstime
: %t
total CPU time で置き換えられます。Benchmark::Tms#total
: %r
実経過時間で置き換えられます。Benchmark::Tms#real
: %n
ラベルで置き換え......られます(Mnemonic: n of "*n*ame")。Benchmark::Tms#label
上記のフォーマット文字列を使用しています。
この定数の内容は以下の通りです。
//emlist[][ruby]{
"%10.6u %10.6y %10.6t %10.6r\n"
//}
@see Benchmark.#benchmark, Benchmark::Tms::FORMAT... -
Benchmark
:: Tms # format(fmtstr = nil , *args) -> String (43.0) -
self を指定されたフォーマットで整形して返します。
...。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::Tms#total
: %r
実経過時間で置き換えられます。Benchmark::Tms#real
: %n
ラベルで置き換えられます(Mnemonic: n of "*n*ame")。Benchmark::Tms#label
@param fmtstr フォーマット文字列です。
省略された場合は、Benchmark::Tms::... -
Benchmark
:: Tms # to _ a -> Array (43.0) -
6 要素の配列を返します。
6 要素の配列を返します。
要素は以下の順番で配列に格納されています。
* ラベル
* user CPU time
* system CPU time,
* 子プロセスの user CPU time
* 子プロセスの system CPU time,
* 実経過時間 -
Benchmark
:: Tms . new(utime = 0 . 0 , stime = 0 . 0 , cutime = 0 . 0 , cstime = 0 . 0 , real = 0 . 0 , label = nil) -> Benchmark :: Tms (43.0) -
新しい Benchmark::Tms オブジェクトを生成して返します。
...新しい Benchmark::Tms オブジェクトを生成して返します。
@param utime User CPU time
@param stime System CPU time
@param cutime 子プロセスの User CPU time
@param cstime 子プロセスの System CPU time
@param real 実経過時間
@param label ラベル... -
Benchmark
:: Tms :: FORMAT -> String (43.0) -
Benchmark.#benchmark の第三引数のデフォルト値。
...
Benchmark.#benchmark の第三引数のデフォルト値。
: %u
user CPU time で置き換えられます。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::Tms#cstime
: %t
total CPU time で置き換えられます。Benchmark::Tms#total
: %r
実経過時間で置き換えられます。Benchmark::Tms#real
: %n
ラベルで置き換え......られます(Mnemonic: n of "*n*ame")。Benchmark::Tms#label
上記のフォーマット文字列を使用しています。
この定数の内容は以下の通りです。
//emlist[][ruby]{
"%10.6u %10.6y %10.6t %10.6r\n"
//}
@see Benchmark.#benchmark, Benchmark::FORMAT... -
Benchmark
. # bmbm(width = 0) {|job| . . . } -> [Benchmark :: Tms] (25.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
. # measure(label = "") { . . . } -> Benchmark :: Tms (25.0) -
与えられたブロックを実行して、経過した時間を Process.#times で計り、 Benchmark::Tms オブジェクトを生成して返します。
...s で計り、
Benchmark::Tms オブジェクトを生成して返します。
Benchmark::Tms オブジェクトには to_s が定義されているので、
基本的には以下のように使います。
//emlist[][ruby]{
require 'benchmark'
puts Benchmark::CAPTION
puts Benchmark.measure { "a"...