Skip to content

Commit

Permalink
Add example for Benchmark.realtime
Browse files Browse the repository at this point in the history
  • Loading branch information
nithinbekal committed Sep 27, 2024
1 parent 3882366 commit 0f278be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f278be

Please sign in to comment.