SPUG: Efficiency of Eval
charles.e.derykus at boeing.com
charles.e.derykus at boeing.com
Mon Dec 6 20:52:28 CST 1999
> use Benchmark;
> timethese( 10_000_000,
> {
> 'eval', sub { eval { sub { die ; }; } },
> 'return', sub { eval { sub { return ; }; } },
> }
> );
> comparing the whole eval-die cycle with the call-return cycle and got:
> ...
> So eval was actually marginally faster.
Um, no. That would just create the code ref's and eliminate
the runtime where the real bottlenecks lurk.
My benchmark was probably flawed too in a different way.
For instance, something like C<sub { 1 }> may be optimized
away. I'm convinced though that the 'eval' will be be slower
and, markedly, if an exception occurs.
rgds,
--
Charles DeRykus
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list