るりまサーチ

最速Rubyリファレンスマニュアル検索!
358件ヒット [301-358件を表示] (0.121秒)
トップページ > クエリ:l[x] > クエリ:>[x] > クエリ:times[x]

別のキーワード

  1. matrix l
  2. _builtin $-l
  3. kernel $-l
  4. lupdecomposition l
  5. l matrix

ライブラリ

モジュール

キーワード

検索結果

<< < ... 2 3 4 >>

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

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

...して、経過した時間を Process.#times で計り、
Benchmark::Tms オブジェクトを生成して返します。

Benchmark::Tms オブジェクトには to_s が定義されているので、
基本的には以下のように使います。

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

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

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

Thread.report_on_exception -> bool (212.0)

真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...は false です。

Thread.new { 1.times { raise } }

は $stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <main>'
1: from -e:1:in `times'

...
...ようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレポートを無効化しても
安全です。しかし、この...
...なかったりするかもしれません。

スレッドごとに設定する方法は Thread#report_on_exception= を参照してください。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。...
...

Thread.new { 1.times { raise } }

は $stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <main>'
1: from -e:1:in `times'

これによって...

Integer#downto(min) {|n| ... } -> self (206.0)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

...self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。

@param min 数値
@return self を返します。

//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}

@see Integer#upto, Numeric#ste...
...p, Integer#times...

ThreadsWait#empty? -> bool (206.0)

同期されるスレッドが存在するならば true をかえします。

...ッドが存在するならば true をかえします。

使用例
require 'thwait'

threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new
p thall.threads.empty? #=> true
thall.join(*threads)
p thall.threads.empty? #=> false...

ThreadsWait#finished? -> bool (206.0)

すでに終了したスレッドが存在すれば true を返します。

...に終了したスレッドが存在すれば true を返します。

使用例
require 'thwait'

threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
p thall.finished? #=> false
sleep 3
p thall.finished? #=> true...

絞り込み条件を変える

ThreadsWait#next_wait(nonblock = nil) -> Thread (206.0)

指定したスレッドのどれかが終了するまで待ちます。

...待ちます。

@param nonblock true を与えると、キューが空の時、例外 ThreadsWait::ErrNoFinishedThread が発生します。

@raise ErrNoWaitingThread 終了をまつスレッドが存在しない時、発生します。

@raise ErrNoFinishedThread nonblock がtrue でかつ、キ...
...ューが空の時、発生します。

#使用例
require 'thwait'

threads = []
2.times {|i|
threads << Thread.new { sleep i }
}

thall = ThreadsWait.new
thall.join_nowait(*threads)
until thall.empty?
th = thall.next_wait
p th
end

@see Queue#pop...

Rubyの起動 (114.0)

Rubyの起動 * cmd_option * shebang

...います。

ruby [ option ...] [ -- ] [ programfile ] [ argument ...]

ここで、option は後述のcmd_option
のいずれかを指定します。-- は、オプション列の終りを明示するため
に使用できます。programfile は、Ruby スクリプトを記述したファイ...
...

//emlist{
# 変更しない場合

$ ruby -e 'p Encoding.default_external; p Encoding.default_internal'
#<Encoding:UTF-8>
nil


# 外部エンコーディングをEUC-JPにする場合

$ ruby -E EUC-JP -e 'p Encoding.default_external; p Encoding.default_internal'
#<Encoding:EUC-JP>
nil

$ ruby...
...各スクリプトの間に改行を
挟んで解釈します。
//emlist{
以下は等価です。
ruby -e "5.times do |i|" -e "puts i" -e "end"

ruby -e "5.times do |i|
puts i
end"

ruby -e "5.times do |i|; puts i; end"
//}

: -Fregexp

入力フィールドセパレ...
<< < ... 2 3 4 >>