From: MonkeeSage Date: 2007-12-21T21:39:58+09:00 Subject: Re: Is there any way to pass further the "hidden" block? On Dec 17, 7:49 pm, MonkeeSage wrote: > Hmmm...another thing...passing prc to #explicit_blk as an lval rather > than invoking block_pass shaves another second off the time... > > def explicit_blk(blk) > blk.call("baz") > end > n = 1_000_000 > prc = lambda { | y | y } > Benchmark.bm(10) { | x | > x.report("explicit") { n.times { explicit_blk(prc) } } > > } > > # => > user system total real > explicit 5.030000 0.520000 5.550000 ( 5.774020) > > ...so I'm curious about two matters: > > 1.) Why does creating a Proc explicitly and passing it as a block_arg > rather than using a literal block (see previous post) speed up the > #explicit_blk benchmark 2 times, but doesn't have very much effect the > #implicit_blk benchmark? > > 2.) Why is it less expensive to pass a Proc as an lval rather than as > a block_arg? > > Anybody know? > > Regards, > Jordan Bump