I am currently doing Test First programming and am stuck on the 06_performance monitor problem located at http://testfirst.org/live/learn_ruby/performance_monitor I found a similar thread on stackoverflow but I still am not understanding the problem. I am failing the last two tests on finding the average run time of multiple blocks. My code so far is:
def measure(i=1)
if i>1
i.times do
yield
end
else
x = Time.now
yield
elapsed_time = Time.now - x
end
end
I am very confused at what the test is trying to do. So far this is what I think I have to do:
I believe the task is to find how long certain blocks take to run. However, I am not sure exactly why this code is even working for the first few tests. And also I am having issues with knowing exactly what the yield statement is returning. I would really appreciate it if someone could walk me through the process of solving this problem so that I understand the solution.