The spec is expecting that the performance monitor doesn't return the total of the times, but average. Your current version of the code is returning neither the total, nor the average, but the count of the times the yield
statement was called.
Your current version of the solution is failing with the following error:
1) Performance Monitor returns the average time, not the total time, when running multiple times
Failure/Error: average_time.should == 6.5
expected: 6.5
got: 4 (using ==)
# ./06_performance_monitor/performance_monitor_spec.rb:64
So you are returning the count and not the average of [8,6,5,7]
.
If the spec fails with the following error, it is returning the sum ( 26.0 = 8 + 6+ 5 + 7 )
:
1) Performance Monitor returns the average time, not the total time, when running multiple times
Failure/Error: average_time.should == 6.5
expected: 6.5
got: 26.0 (using ==)
# ./06_performance_monitor/performance_monitor_spec.rb:64
Couple of pointers to help you move forward:
Look at your assumption that the count should default to 0 (as defined by x=0
param being passed to measure
. If the program calls measure
without any parameters, wouldn't it make sense to say it has been called once rather than zero times?
Try to understand why your program is returning 4
by walking through the code for measure
on each value of [8,6,5,7], and by modifying/adding new test cases in performance_monitor_spec.rb
file. Hint: The code isn't doing any performance monitoring in this path ;-)