るりまサーチ

最速Rubyリファレンスマニュアル検索!
132件ヒット [1-100件を表示] (0.009秒)
トップページ > クエリ:total[x] > 種類:モジュール関数[x]

別のキーワード

  1. tms total
  2. zlib total_in
  3. zlib total_out
  4. benchmark total
  5. zstream total_in

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 > >>

Benchmark.#benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|rep| ...} -> [Benchmark::Tms] (37.0)

Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。

...hmark::Tms#cutime
: %Y
子プロセスの system CPU time で置き換えられます。Benchmark::Tms#cstime
: %t
total
CPU time で置き換えられます。Benchmark::Tms#total
: %r
実経過時間で置き換えられます。Benchmark::Tms#real
: %n
ラベルで置き換えられます...
...'benchmark'

n = 50000

# これは
# Benchmark.bm(7, ">total:", ">avg:") do |x| ... end
# と同じ
Benchmark.benchmark(" "*7 + Benchmark::CAPTION,
7,
Benchmark::FORMAT,
">total:",
">avg:") do |x|

tf = x.report("f...
...+tt+tu)/3]
end

#=>
#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
# upto: 1.533333 0.000000 1.533333 ( 0.722166)
# >total: 4.000000 0.033333 4.033333 ( 1.889282)
# >a...

Benchmark.#bm(label_width = 0, *labels) {|rep| ... } -> [Benchmark::Tms] (31.0)

Benchmark.#benchmark メソッドの引数を簡略化したものです。

...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 ( 0.492106)
# 1.483333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000000 1.516667 ( 0.7...
...stem total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
//}

集計を付けた場合

//emlist[][ruby]{
require 'benchmark'

n = 50000
Benchmark.bm(7, ">total:",...
...tu) / 3]
end

#=>
# user system total real
# for: 0.001467 0.004727 0.006194 ( 0.006193)
# times: 0.003814 0.000000 0.003814 ( 0.003814)
# upto: 0.003855 0.000003 0.003858 ( 0.003859)
# >total: 0.009136 0.004730 0.013866 ( 0.013867)
#...

ObjectSpace.#each_object -> Enumerator (25.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...jectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)...
...s1 = Person.new("tanaka")
s2 = Person.new("sato")

count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

ObjectSpace.#each_object {|object| ...} -> Integer (25.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...jectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)...
...s1 = Person.new("tanaka")
s2 = Person.new("sato")

count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

ObjectSpace.#each_object(klass) -> Enumerator (25.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...jectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)...
...s1 = Person.new("tanaka")
s2 = Person.new("sato")

count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

絞り込み条件を変える

ObjectSpace.#each_object(klass) {|object| ...} -> Integer (25.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...jectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)...
...s1 = Person.new("tanaka")
s2 = Person.new("sato")

count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

ObjectSpace.#memsize_of_all(klass = nil) -> Integer (19.0)

すべての生存しているオブジェクトが消費しているメモリ使用量をバイト単位 で返します。

...ドで定義できます。

//emlist[例][ruby]{
def memsize_of_all klass = false
total
= 0
ObjectSpace.each_object{|e|
total
+= ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass)
}
total

end
//}

戻り値の内容は完全ではない事に注意してください。こ...

Benchmark.#bmbm(width = 0) {|job| ... } -> [Benchmark::Tms] (13.0)

Benchmark::Job オブジェクトを生成して、それを引数として与えられたブロックを 実行します。

....010000 11.938000 ( 12.756000)
# sort 13.048000 0.020000 13.068000 ( 13.857000)
# ------------------------------- total: 25.006000sec
#
# user system total real
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
# sort 12.007000 0.000000 12.007000 ( 12.79100...

Benchmark.#measure(label = "") { ... } -> Benchmark::Tms (7.0)

与えられたブロックを実行して、経過した時間を Process.#times で計り、 Benchmark::Tms オブジェクトを生成して返します。

...は to_s が定義されているので、
基本的には以下のように使います。

//emlist[][ruby]{
require 'benchmark'

puts Benchmark::CAPTION
puts Benchmark.measure { "a"*1_000_000 }

#=>
#
# user system total real
# 1.166667 0.050000 1.216667 ( 0.571355)
//}...
<< 1 2 > >>