ruby-changes:35180
From: normal <ko1@a...>
Date: Sun, 24 Aug 2014 11:10:35 +0900 (JST)
Subject: [ruby-changes:35180] normal:r47262 (trunk): lib/benchmark.rb (measure): reduce allocations as in r47260
normal 2014-08-24 11:10:28 +0900 (Sun, 24 Aug 2014) New Revision: 47262 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47262 Log: lib/benchmark.rb (measure): reduce allocations as in r47260 Modified files: trunk/ChangeLog trunk/lib/benchmark.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 47261) +++ ChangeLog (revision 47262) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Aug 24 11:09:29 2014 Eric Wong <e@8...> + + * lib/benchmark.rb (measure): reduce allocations as in r47260 + Sun Aug 24 10:35:54 2014 Pete Higgins <pete@p...> * lib/benchmark.rb (module Benchmark): define BENCHMARK_CLOCK Index: lib/benchmark.rb =================================================================== --- lib/benchmark.rb (revision 47261) +++ lib/benchmark.rb (revision 47262) @@ -270,14 +270,22 @@ module Benchmark https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L270 STDOUT.sync = sync unless sync.nil? end + # :stopdoc: + if defined?(Process::CLOCK_MONOTONIC) + BENCHMARK_CLOCK = Process::CLOCK_MONOTONIC + else + BENCHMARK_CLOCK = Process::CLOCK_REALTIME + end + # :startdoc: + # # Returns the time used to execute the given block as a # Benchmark::Tms object. # def measure(label = "") # :yield: - t0, r0 = Process.times, Time.now + t0, r0 = Process.times, Process.clock_gettime(BENCHMARK_CLOCK) yield - t1, r1 = Process.times, Time.now + t1, r1 = Process.times, Process.clock_gettime(BENCHMARK_CLOCK) Benchmark::Tms.new(t1.utime - t0.utime, t1.stime - t0.stime, t1.cutime - t0.cutime, @@ -286,14 +294,6 @@ module Benchmark https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L294 label) end - # :stopdoc: - if defined?(Process::CLOCK_MONOTONIC) - BENCHMARK_CLOCK = Process::CLOCK_MONOTONIC - else - BENCHMARK_CLOCK = Process::CLOCK_REALTIME - end - # :startdoc: - # # Returns the elapsed real time used to execute the given block. # -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/