From 29674ec6bacf2dc0c44825112632535a842325af Mon Sep 17 00:00:00 2001 From: Randy Stauner Date: Tue, 16 Jul 2024 16:39:17 -0700 Subject: [PATCH] Simplify realtime method We probably aren't running these benchmarks on rubies that don't have these methods. If we are, they probably don't have their own alternate implementation of Benchmark.realtime. If we need to support something else we should just add a version that uses Time.now.to_f. --- harness/harness.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/harness/harness.rb b/harness/harness.rb index eec45a21..9fa868d2 100644 --- a/harness/harness.rb +++ b/harness/harness.rb @@ -18,18 +18,10 @@ puts RUBY_DESCRIPTION -if defined?(Process.clock_gettime) && defined?(Process::CLOCK_MONOTONIC) - def realtime - r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) - yield - Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0 - end -else - require "benchmark" - - def realtime(&block) - Benchmark.realtime(&block) - end +def realtime + r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) + yield + Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0 end # Takes a block as input