るりまサーチ

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

別のキーワード

  1. rubygems/user_interaction new
  2. rubygems/user_interaction done
  3. rubygems/user_interaction count
  4. rubygems/user_interaction updated
  5. http proxy_user

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 > >>

Syslog.#open(ident=$0, options=Syslog::LOG_PID|Syslog::LOG_CONS, facility=Syslog::LOG_USER) { |syslog| ... } -> self (103.0)

与えられた引数でsyslogを開きます。以降、他の Syslog モジュール関数が使 用可能となります。

与えられた引数でsyslogを開きます。以降、他の Syslog モジュール関数が使
用可能となります。

ブロック付きで呼ばれた場合は、self を引数としてブロックを実行し、
最後に Syslog.#close を行います。

syslog の詳細については syslog(3) を参照してください。

@param ident すべてのログにつく識別子で、どのプログラムから送られ
たログなのかを識別するために使われる文字列を指定します。
指定しない場合はプログラム名が使われます。

@param options Syslog.open ...

Syslog.#reopen(ident=$0, options=Syslog::LOG_PID|Syslog::LOG_CONS, facility=Syslog::LOG_USER) { |syslog| ... } -> self (103.0)

開いていた syslog を最初にクローズする点を除いてSyslog.#open と同じです。

開いていた syslog を最初にクローズする点を除いてSyslog.#open と同じです。

@param ident すべてのログにつく識別子で、どのプログラムから送られ
たログなのかを識別するために使われる文字列を指定します。
指定しない場合はプログラム名が使われます。

@param options Syslog.open や Syslog.log の動作を制御するフラグを指定します。
指定しない場合は、Syslog::LOG_PID|Syslog::LOG_CONSの値が使われ
...

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (73.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `...
...test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (73.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `...
...test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

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

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

...字列として以下が使用できます。

: %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:...
...("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 1.466667 ( 0.6813...

絞り込み条件を変える

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

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

...|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 ( 0.492106)
# 1.483333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000...
...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.7354...
...:") { 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.000000 0.003814 ( 0.0...

Etc.#getlogin -> String | nil (19.0)

自分の login 名を返します。得られなかった場合は nil を返します。

...c.#getpwuid に
フォールバックするとよいでしょう。

たとえば、環境変数 USER などもあわせて、以下のようにフォールバックできます。

//emlist[][ruby]{
require "etc"
login_user = ENV['USER'] || ENV['LOGNAME'] || Etc.getlogin || Etc.getpwuid.name
//}...

Benchmark.#bmbm(width = 0) {|job| ... } -> [Benchmark::Tms] (7.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.791000...

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 3 > >>