ruby-changes:38459
From: hsbt <ko1@a...>
Date: Tue, 19 May 2015 17:15:29 +0900 (JST)
Subject: [ruby-changes:38459] hsbt:r50540 (trunk): * lib/benchmark.rb: Update Benchmark documentation and formatting.
hsbt 2015-05-19 17:15:07 +0900 (Tue, 19 May 2015) New Revision: 50540 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50540 Log: * lib/benchmark.rb: Update Benchmark documentation and formatting. [fix GH-903][ci skip] Modified files: trunk/ChangeLog trunk/lib/benchmark.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 50539) +++ ChangeLog (revision 50540) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue May 19 17:15:03 2015 SHIBATA Hiroshi <hsbt@r...> + + * lib/benchmark.rb: Update Benchmark documentation and formatting. + [fix GH-903][ci skip] + Tue May 19 13:10:08 2015 Nobuyoshi Nakada <nobu@r...> * numeric.c (num_positive_p): should false on Bignum 0. Index: lib/benchmark.rb =================================================================== --- lib/benchmark.rb (revision 50539) +++ lib/benchmark.rb (revision 50540) @@ -131,7 +131,7 @@ module Benchmark https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L131 # # 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 https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L180 # 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 https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L281 # # 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 https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L488 # # 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 https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L500 # <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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/