ruby-changes:38643
From: normal <ko1@a...>
Date: Tue, 2 Jun 2015 09:08:44 +0900 (JST)
Subject: [ruby-changes:38643] normal:r50724 (trunk): lib/benchmark.rb: just use Process::CLOCK_MONOTONIC
normal 2015-06-02 09:08:25 +0900 (Tue, 02 Jun 2015) New Revision: 50724 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50724 Log: lib/benchmark.rb: just use Process::CLOCK_MONOTONIC Assume Process::CLOCK_MONOTONIC exists (possibly emulated) and there is no need to bloat our code by defining a compatibility constant. * lib/benchmark.rb: just use Process::CLOCK_MONOTONIC [ruby-core:69390] Modified files: trunk/ChangeLog trunk/lib/benchmark.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 50723) +++ ChangeLog (revision 50724) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jun 2 09:04:14 2015 Eric Wong <e@8...> + + * lib/benchmark.rb: just use Process::CLOCK_MONOTONIC + [ruby-core:69390] + Mon Jun 1 22:01:27 2015 Nobuyoshi Nakada <nobu@r...> * lib/mkmf.rb (pkg_config): split --libs if --libs-only-l option Index: lib/benchmark.rb =================================================================== --- lib/benchmark.rb (revision 50723) +++ lib/benchmark.rb (revision 50724) @@ -270,15 +270,6 @@ module Benchmark https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L270 STDOUT.sync = sync unless sync.nil? end - # :stopdoc: - case - when 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. Takes +label+ option. @@ -297,9 +288,9 @@ module Benchmark https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L288 # 0.220000 0.000000 0.220000 ( 0.227313) # def measure(label = "") # :yield: - t0, r0 = Process.times, Process.clock_gettime(BENCHMARK_CLOCK) + t0, r0 = Process.times, Process.clock_gettime(Process::CLOCK_MONOTONIC) yield - t1, r1 = Process.times, Process.clock_gettime(BENCHMARK_CLOCK) + t1, r1 = Process.times, Process.clock_gettime(Process::CLOCK_MONOTONIC) Benchmark::Tms.new(t1.utime - t0.utime, t1.stime - t0.stime, t1.cutime - t0.cutime, @@ -312,9 +303,9 @@ module Benchmark https://github.com/ruby/ruby/blob/trunk/lib/benchmark.rb#L303 # Returns the elapsed real time used to execute the given block. # def realtime # :yield: - r0 = Process.clock_gettime(BENCHMARK_CLOCK) + r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield - Process.clock_gettime(BENCHMARK_CLOCK) - r0 + Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0 end module_function :benchmark, :measure, :realtime, :bm, :bmbm -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/