From cb1affb47890013d653d4ec50fe3f042abc286c6 Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 2 Jun 2015 00:08:25 +0000 Subject: 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/benchmark.rb | 17 ++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35d2f9f82b..87ef36bdf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jun 2 09:04:14 2015 Eric Wong + + * lib/benchmark.rb: just use Process::CLOCK_MONOTONIC + [ruby-core:69390] + Mon Jun 1 22:01:27 2015 Nobuyoshi Nakada * lib/mkmf.rb (pkg_config): split --libs if --libs-only-l option diff --git a/lib/benchmark.rb b/lib/benchmark.rb index 95ff419aef..1e2b8d2d38 100644 --- a/lib/benchmark.rb +++ b/lib/benchmark.rb @@ -270,15 +270,6 @@ module Benchmark 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 # 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 # 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 -- cgit v1.2.3