From: Robert Klemme Date: 2008-01-09T02:35:07+09:00 Subject: Re: Using benchmark for wait times On 08.01.2008 18:02, Max Russell wrote: > I’m trying to use Benchmark, to return the wait time for a search in an > application, and thought I could fairly neatly wrap up the wait time > like this: > > $logger.log(Benchmark.measure($ie.wait())) > > However, when I run this test from my harness, I get the following in > the console: > > LocalJumpError: no block given > C:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' > ./Tests/test_audittrail.rb:119 > ./Tests/test_audittrail.rb:61:in `each' > ./Tests/test_audittrail.rb:61 > C:/workspace/CV_Auto/harness.rb:41:in `load' > C:/workspace/CV_Auto/harness.rb:41:in `test_audittrail' > > > What confuses me further is that line 61 reads: > message_type.each do |link| > $logger.log("") > > which when I diff it against my last version, I can see has not changed. > > What I’d like to know is: > > Am I off the mark wrapping the wait in a measure and then logging it? > > Why does my each statement now fail? You are not "wrapping the wait in a measure". Instead you invoke #wait and stuff the result into #measure. Consider this: robert@fussel ~ $ ruby -r benchmark -e 'puts Benchmark.measure( sleep(1) )' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure': no block given (LocalJumpError) from -e:1 robert@fussel ~ $ ruby -r benchmark -e 'puts Benchmark.measure{ sleep(1) }' 0.000000 0.000000 0.000000 ( 1.000000) Cheers robert