summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/benchmark.rb17
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 <e@80x24.org>
+
+ * lib/benchmark.rb: just use Process::CLOCK_MONOTONIC
+ [ruby-core:69390]
+
Mon Jun 1 22:01:27 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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