summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-19 08:15:07 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-19 08:15:07 +0000
commitcdea1553b34f884443427b2ba250baed563e1ce3 (patch)
treef3e9067e800f56d9bea557b7dd992cd50fa92470 /lib
parent59b089bd0902ee5de3b8fdb846fe9ece1c49b494 (diff)
* lib/benchmark.rb: Update Benchmark documentation and formatting.
[fix GH-903][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/benchmark.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 690dff1c28..95ff419aef 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -131,7 +131,7 @@ module Benchmark
#
# If the block returns an array of
# Benchmark::Tms objects, these will be used to format
- # additional lines of output. If +label+ parameters are
+ # additional lines of output. If +labels+ parameter are
# given, these are used to label these extra lines.
#
# _Note_: Other methods provide a simpler interface to this one, and are
@@ -180,8 +180,8 @@ module Benchmark
# A simple interface to the #benchmark method, #bm generates sequential
- # reports with labels. The parameters have the same meaning as for
- # #benchmark.
+ # reports with labels. +label_width+ and +labels+ parameters have the same
+ # meaning as for #benchmark.
#
# require 'benchmark'
#
@@ -281,7 +281,20 @@ module Benchmark
#
# Returns the time used to execute the given block as a
- # Benchmark::Tms object.
+ # Benchmark::Tms object. Takes +label+ option.
+ #
+ # require 'benchmark'
+ #
+ # n = 1000000
+ #
+ # time = Benchmark.measure do
+ # n.times { a = "1" }
+ # end
+ # puts time
+ #
+ # Generates:
+ #
+ # 0.220000 0.000000 0.220000 ( 0.227313)
#
def measure(label = "") # :yield:
t0, r0 = Process.times, Process.clock_gettime(BENCHMARK_CLOCK)
@@ -475,7 +488,7 @@ module Benchmark
#
# Returns the contents of this Tms object as
- # a formatted string, according to a format string
+ # a formatted string, according to a +format+ string
# like that passed to Kernel.format. In addition, #format
# accepts the following extensions:
#
@@ -487,7 +500,7 @@ module Benchmark
# <tt>%r</tt>:: Replaced by the elapsed real time, as reported by Tms#real
# <tt>%n</tt>:: Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
#
- # If _format_ is not given, FORMAT is used as default value, detailing the
+ # If +format+ is not given, FORMAT is used as default value, detailing the
# user, system and real elapsed time.
#
def format(format = nil, *args)