Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
The easiest way is to create a variable before the loop into which to write the current time, and create a variable after the loop into which to write the time.
We apply the arithmetic operation time2 - time1 and get the output of the loop execution time
begin_time = Time.now
10.times do
sleep(1)
end
puts Time.now - begin_time
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question