るりまサーチ

最速Rubyリファレンスマニュアル検索!
309件ヒット [1-100件を表示] (0.076秒)

別のキーワード

  1. _builtin to_c
  2. etc sc_2_c_dev
  3. etc sc_2_c_bind
  4. tracer display_c_call
  5. tracer display_c_call=

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Kernel.#system(command, options={}) -> bool | nil (18237.0)

引数を外部コマンドとして実行して、成功した時に真を返します。

...の終了ステータスの場合は false を返します。
コマンドを実行できなかった場合は nil を返します。

options で :exception に true を指定することで、
nil や false を返す代わりに例外を発生するようにできます。

終了ステータス...
...数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。

@param command command コマンドを文字列で...
...表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX exception: true が指定されていて、コマンドの実行が失敗したときに発生します。
@raise RuntimeError exception: true が指定されていて、コマンドの終了ステータスが 0 以外...

Kernel.#system(env, command, options={}) -> bool | nil (18237.0)

引数を外部コマンドとして実行して、成功した時に真を返します。

...の終了ステータスの場合は false を返します。
コマンドを実行できなかった場合は nil を返します。

options で :exception に true を指定することで、
nil や false を返す代わりに例外を発生するようにできます。

終了ステータス...
...数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。

@param command command コマンドを文字列で...
...表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX exception: true が指定されていて、コマンドの実行が失敗したときに発生します。
@raise RuntimeError exception: true が指定されていて、コマンドの終了ステータスが 0 以外...

Kernel.#system(command, options={}) -> bool | nil (18219.0)

引数を外部コマンドとして実行して、成功した時に真を返します。

...数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。

@param command command コマンドを文字列で...
...指定します。
@param env 更新する環境変数を表す Hash
@param options オプションパラメータ Hash

//emlist[シェル経由でコマンドを実行][ruby]{
system
("echo *") # => true
# fileA fileB fileC ...
//}


@see Kernel.#`,Kernel.#spawn,Kernel.#exec,system(3)...

Kernel.#system(env, command, options={}) -> bool | nil (18219.0)

引数を外部コマンドとして実行して、成功した時に真を返します。

...数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。

@param command command コマンドを文字列で...
...指定します。
@param env 更新する環境変数を表す Hash
@param options オプションパラメータ Hash

//emlist[シェル経由でコマンドを実行][ruby]{
system
("echo *") # => true
# fileA fileB fileC ...
//}


@see Kernel.#`,Kernel.#spawn,Kernel.#exec,system(3)...

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

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

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

基本的には以下のように使います。
ブロックが Benchmark::Tms オブジェクトの配列を返した場合は、
それらの数値も追加の行に表示...
...れます。

@param caption レポートの一行目に表示する文字列を指定します。
@param label_width ラベルの幅を指定します。
@param fmtstr フォーマット文字列を指定します。
この引数を省略すると Benchmark::FORMAT が...
...ロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。

=== フォーマット文字列

フォーマット文字列として以下が使用できます。

: %u
user CPU time で置き換えられます。Benchmark::Tms#utime
: %y
system
CPU time で置き...

絞り込み条件を変える

Kernel.#exec(env, program, *args, options={}) -> () (6107.0)

引数で指定されたコマンドを実行します。

...に成功した場合、このメソッドからは戻りません。

この形式では、常に shell を経由せずに実行されます。

exec(3) でコマンドを実行すると、
元々のプログラムの環境をある程度(ファイルデスクリプタなど)引き継ぎます。
H...
...
@raise Errno::EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。



//emlist[例][ruby]{
# a.rb
exec ['sleep', 'mysleep'], '600'
//}

上記スクリプトを実行すると以下のようになります。

$ ruby a.rb
## sleep してるので...
...替えて以下を実行
$ ps aux|grep sleep
xxxx 32754 0.0 0.0 2580 468 pts/3 S+ 22:01 0:00 mysleep 600
xxxx 32761 0.0 0.0 2824 792 pts/6 S+ 22:01 0:00 grep sleep

@see Kernel.#system,Kernel.#`,Kernel.#spawn,Kernel.#fork,IO.popen,IO.pipe,Kernel.#open,exec(3)...

Kernel.#exec(program, *args, options={}) -> () (6107.0)

引数で指定されたコマンドを実行します。

...に成功した場合、このメソッドからは戻りません。

この形式では、常に shell を経由せずに実行されます。

exec(3) でコマンドを実行すると、
元々のプログラムの環境をある程度(ファイルデスクリプタなど)引き継ぎます。
H...
...
@raise Errno::EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。



//emlist[例][ruby]{
# a.rb
exec ['sleep', 'mysleep'], '600'
//}

上記スクリプトを実行すると以下のようになります。

$ ruby a.rb
## sleep してるので...
...替えて以下を実行
$ ps aux|grep sleep
xxxx 32754 0.0 0.0 2580 468 pts/3 S+ 22:01 0:00 mysleep 600
xxxx 32761 0.0 0.0 2824 792 pts/6 S+ 22:01 0:00 grep sleep

@see Kernel.#system,Kernel.#`,Kernel.#spawn,Kernel.#fork,IO.popen,IO.pipe,Kernel.#open,exec(3)...

Kernel.#exec(command, options={}) -> () (6102.0)

引数で指定されたコマンドを実行します。

...== 引数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。

@param command コマンドを文字列で指...
...:EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。

//emlist[例][ruby]{
# a.rb
puts '実行前'
exec 'echo "実行中"'
puts '実行後'
//}

上記のスクリプトを実行すると以下のようになります。

$ ruby a.rb
実行前
...

Kernel.#exec(env, command, options={}) -> () (6102.0)

引数で指定されたコマンドを実行します。

...== 引数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。

@param command コマンドを文字列で指...
...:EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。

//emlist[例][ruby]{
# a.rb
puts '実行前'
exec 'echo "実行中"'
puts '実行後'
//}

上記のスクリプトを実行すると以下のようになります。

$ ruby a.rb
実行前
...

Benchmark.#bm(label_width = 0, *labels) {|rep| ... } -> [Benchmark::Tms] (3125.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 (...
...//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("upto:") { 1.upto(n) do ; a = "1"; end }
end

#=>
# user system total real
# for:...

絞り込み条件を変える

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

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

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

ベンチマークの結果は GC の影響によって歪められてしまうことがあります。
このメソッドは与えられたブロックを二度実行する...
...番として
実行します。

二回目のブロック実行の前に GC.start を実行しますが、この実行時間は計測には
含まれません。しかし、実際にはこのメソッドを使用しても、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 -----------------------------------------
# sort! 11.928...
<< 1 2 3 ... > >>