77件ヒット
[1-77件を表示]
(0.072秒)
検索結果
先頭5件
- Process
. # times -> Process :: Tms - Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] - Process
. # clock _ gettime(clock _ id , unit=:float _ second) -> Float | Integer - Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] - Benchmark
. # measure(label = "") { . . . } -> Benchmark :: Tms
-
Process
. # times -> Process :: Tms (18102.0) -
自身のプロセスとその子プロセスが消費したユーザ/システム CPU 時間の積算を Process::Tms オブジェクトで返します。 時間の単位は秒で、浮動小数点数で与えられます。
自身のプロセスとその子プロセスが消費したユーザ/システム CPU 時間の積算を
Process::Tms オブジェクトで返します。
時間の単位は秒で、浮動小数点数で与えられます。
@raise NotImplementedError メソッドが現在のプラットフォームで実装されていない場合に発生します。
@see Process::Tms -
Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] (43.0) -
Benchmark.#benchmark メソッドの引数を簡略化したものです。
...指定します。
//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.......or i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
end
#=>
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.......}
tt = x.report("times:") { n.times do ; a = "1"; end }
tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
[tf + tt + tu, (tf + tt + tu) / 3]
end
#=>
# user system total real
# for: 0.001467 0.004727 0.006194 ( 0.006193)
# times: 0.003814 0.... -
Process
. # clock _ gettime(clock _ id , unit=:float _ second) -> Float | Integer (31.0) -
POSIX の clock_gettime() 関数の時間を返します。
...れかで指定します。
サポートされている定数は OS やバージョンに依存します。
: Process::CLOCK_REALTIME
SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12
: Process::CLOCK_MONOTONIC
SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBS......:GETTIMEOFDAY_BASED_CLOCK_REALTIME と定義されています。
CLOCK_REALTIME のエミュレーション:
: :GETTIMEOFDAY_BASED_CLOCK_REALTIME
SUS で定義されている gettimeofday() を使います。 (しかし SUSv4 で obsoleted になっています)
精度は1マイクロ秒です......可能な mach_absolute_time() を使います。
精度は CPU に依存します。
: :TIMES_BASED_CLOCK_MONOTONIC
POSIX で定義されている times() の結果を使います。
POSIX では「times() は過去のある時点 (例えばシステムの起動時刻) からの経過クロッ... -
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (19.0) -
Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
...end }
tt = x.report("times:") { n.times do ; a = "1"; end }
tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
[tf+tt+tu, (tf+tt+tu)/3]
end
#=>
#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667... -
Benchmark
. # measure(label = "") { . . . } -> Benchmark :: Tms (17.0) -
与えられたブロックを実行して、経過した時間を Process.#times で計り、 Benchmark::Tms オブジェクトを生成して返します。
...与えられたブロックを実行して、経過した時間を Process.#times で計り、
Benchmark::Tms オブジェクトを生成して返します。
Benchmark::Tms オブジェクトには to_s が定義されているので、
基本的には以下のように使います。
//emlist[]... -
Kernel
. # at _ exit { . . . } -> Proc (7.0) -
与えられたブロックをインタプリタ終了時に実行します。
...。
spec/terminateも参照してください。
@return 登録した処理を Proc オブジェクトで返します。
//emlist[例][ruby]{
3.times do |i|
at_exit{puts "at_exit#{i}"}
end
END{puts "END"}
at_exit{puts "at_exit"}
puts "main_end"
#=> main_end
# at_exit
# END
# at_exit2
#... -
Process
. # waitall -> [[Integer , Process :: Status]] (7.0) -
全ての子プロセスが終了するのを待ちます。 終了した子プロセスの pid と終了ステータス (Process::Status) の配列の配列を返します。 子プロセスがいない状態でこのメソッドを呼び出すと空の配列を返します。
...空の配列を返します。
$? には最後に終了した子プロセスの Process::Status オブジェクトが設定されます。
2.times {|n|
Process.fork() { exit n }
}
p Process.waitall
#=> :Status: pid=2766,exited(1)>], [2765, #<Process::Status: pid=2765,exited(1...