我正在构建 Test-First-Teaching performance_monitor 并且可以进行第五次测试,但它失败了。
为什么我的块只运行一次?
这是我的代码:
require "time"
t = Time.now
def measure x=0
start = Time.now
yield x
endt = Time.now - start
end
measure(4){ |x| x.times do Time.now - t end}
这是错误:
*Error____
Performance Monitor
takes about 0 seconds to run an empty block
takes exactly 0 seconds to run an empty block (with stubs)
takes about 1 second to run a block that sleeps for 1 second
takes exactly 1 second to run a block that sleeps for 1 second (with stubs)
runs a block N times (FAILED - 1)
Failures:
1) Performance Monitor runs a block N times
Failure/Error: n.should == 4
expected: 4
got: 1 (using ==)