From 388236685c021a153c5691529c1c91357218f5fd Mon Sep 17 00:00:00 2001 From: Nithin Bekal Date: Thu, 26 Sep 2024 23:37:36 -0400 Subject: [PATCH 1/2] Specify unit of time for Benchmark.realtime --- lib/benchmark.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/benchmark.rb b/lib/benchmark.rb index 9f43255..b2c8df0 100644 --- a/lib/benchmark.rb +++ b/lib/benchmark.rb @@ -307,6 +307,7 @@ def measure(label = "") # :yield: # # Returns the elapsed real time used to execute the given block. + # The unit of time is seconds. # def realtime # :yield: r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) From 0f278be6c1980b83a6dd2421992214a2787ee8ac Mon Sep 17 00:00:00 2001 From: Nithin Bekal Date: Thu, 26 Sep 2024 23:39:21 -0400 Subject: [PATCH 2/2] Add example for Benchmark.realtime --- lib/benchmark.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/benchmark.rb b/lib/benchmark.rb index b2c8df0..5072bdc 100644 --- a/lib/benchmark.rb +++ b/lib/benchmark.rb @@ -309,6 +309,9 @@ def measure(label = "") # :yield: # Returns the elapsed real time used to execute the given block. # The unit of time is seconds. # + # Benchmark.realtime { "a" * 1_000_000_000 } + # #=> 0.5098029999935534 + # def realtime # :yield: r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield