るりまサーチ

最速Rubyリファレンスマニュアル検索!
90件ヒット [1-90件を表示] (0.020秒)
トップページ > クエリ:require[x] > クエリ:benchmark[x]

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

ライブラリ

モジュール

キーワード

検索結果

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

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

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

基本的には以下のように使います。
ブロックが Benchmark::Tms オブジェクトの配列を返した場合は、
それらの数値も追加の行に表示...
...tstr フォーマット文字列を指定します。
この引数を省略すると Benchmark::FORMAT が使用されます。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。

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

...
...Benchmark::Tms#cstime
: %t
total CPU time で置き換えられます。Benchmark::Tms#total
: %r
実経過時間で置き換えられます。Benchmark::Tms#real
: %n
ラベルで置き換えられます(Mnemonic: n of "*n*ame")。Benchmark::Tms#label

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

n...

Benchmark.#bm(label_width = 0, *labels) {|rep| ... } -> [Benchmark::Tms] (17217.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 (...
...1.483333 ( 0.694605)
# 1.516667 0.000000 1.516667 ( 0.711077)
//}

以下のようにも書けます。

//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.repor...

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

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

...s で計り、
Benchmark
::Tms オブジェクトを生成して返します。

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

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

puts Benchmark::CAPTION
puts Benchmark.measure { "a"...

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

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

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

ベンチマークの結果は 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 --...

Benchmark.#realtime { ... } -> Float (17018.0)

与えられたブロックを評価して実行時間を計測して返します。 返り値の単位は、秒です。

...与えられたブロックを評価して実行時間を計測して返します。
返り値の単位は、秒です。

//emlist[][ruby]{
require
'benchmark'
puts Benchmark.realtime { [0] * (10**8) } # => 1.0929416846483946
//}...

絞り込み条件を変える

Ruby用語集 (24.0)

Ruby用語集 A B C D E F G I J M N O R S Y

...まれているクラス。
ライブラリーを require することなく使うことができる。

参照:_builtin

: 組み込みライブラリー
: built-in library
Ruby 本体に組み込まれているライブラリー。require せずに使うことができる。

: クラス
:...
...ス変数、クラス変数がある。
変数とよく似たものとして、定数がある。

→代入

: ベンチマークテスト
: benchmark test
プログラムの速度性能を調べるソフトウェアテスト。
ベンチマークテストを行うため、各種の専用...
...る。

Ruby 2.7 以降では case/in の As パターンでも使う。

参照:d:spec/literal#hash

: ロードパス
スクリプトを require、load などで読み込む(ロードする)とき、
ファイルの位置を絶対パスで与えなくても、ファイル名(拡張...

NEWS for Ruby 2.7.0 (18.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...以前のlazyではないEnumerator#with_indexのデフォルト実装から
lazyになりました。7877

//emlist[Enumerator.produce][ruby]{
require
"date"
dates = Enumerator.produce(Date.today, &:succ) #=> infinite sequence of dates
dates.detect(&:tuesday?) #=> next Tuesday
//}
//emlist[Enume...
...ionParser
* 不明なオプションに対して "Did you mean?" が表示されるようになりました。 16256

//emlist[test.rb][ruby]{
require
"optparse"
OptionParser.new do |opts|
opts.on("-f", "--foo", "foo") {|v| }
opts.on("-b", "--bar", "bar") {|v| }
opts.on("-c", "--baz", "baz...
...下のライブラリが新たにdefault gemsになりました。
* 以下のdefault gemがrubygems.orgで公開されました。
* benchmark
* cgi
* delegate
* getoptlong
* net-pop
* net-smtp
* open3
* pstore
* readline
* readline-ex...

rubygems (18.0)

RubyGems を扱うためのクラスやモジュールが定義されているライブラリです。

...es を追加しています。

また、以下のように Rakefile にタスクを追加することもできます。

//emlist[gemspec][ruby]{
require
'rake/gempackagetask'

PKG_FILES = FileList[
'lib/hello.rb',
'spec/*'
]
spec = Gem::Specification.new do |s|
s.name = 'hello'...
...'http://example.com/hello'
s.platform = Gem::Platform::RUBY
s.summary = 'Hello Gem'
s.files = PKG_FILES.to_a
s.require_path = 'lib'
s.has_rdoc = false
s.extra_rdoc_files = ['README']
end

Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spe...
...ーマットで書かれたファイルを置くことでも
動作を変更することができます。

例:

---
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- https://rubygems.org
:update_sources: true
:verbose: true
gemhome: /home/hoge/.gems
gempath...