2008/9/10, Peña, Botp <botp / delmonte-phil.com>:
> From: Iñaki Baz Castillo [mailto:ibc / aliax.net]
>  # >> Benchmark.realtime { instance_eval 'a=123; a2=a*2; a3=a*3' }
>  # # => 4.50611114501953e-05
>
>  that's a string.
>
>  include a block, eg
>
>
>  > Benchmark.realtime { a=123; a2=a*2; a3=a*3 }
>
> => 1.59740447998047e-05
>
>
>  > Benchmark.realtime { instance_eval 'a=123; a2=a*2; a3=a*3' }
>
> => 7.58171081542969e-05
>
>
>  > Benchmark.realtime { instance_eval {a=123; a2=a*2; a3=a*3} }
>
> => 2.288818359375e-05


You are right!
So using "instance_eval" is ~  40% slower than running directly the code.

Thanks a lot.


-- 
Iñaki Baz Castillo
<ibc / aliax.net>