in reply to Re: How expensive is eval { }?
in thread How expensive is eval { }?

This benchmark result seems to vary strongly with the platform and/or perl version.

Debian GNU/Linux i386 (32 bit, SMP):

$ perl5.8.8 foo.pl Rate ForExcept BareFor ExceptFor ForExcept 2511/s -- -34% -34% BareFor 3794/s 51% -- -1% ExceptFor 3829/s 52% 1% -- $ perl5.10.0 foo.pl Rate ForExcept BareFor ExceptFor ForExcept 2393/s -- -29% -30% BareFor 3350/s 40% -- -2% ExceptFor 3429/s 43% 2% --

That's quite different from the 2% .. 13%.

Any idea why the differences between the perl versions and platforms are that big?

Replies are listed 'Best First'.
Re^3: How expensive is eval { }?
by GrandFather (Saint) on Apr 17, 2008 at 10:05 UTC

    No real idea, but bear in mind that most likely we are looking at only a few instructions' execution time difference between each case so they could be highly sensitive to optimization or modest differences in instruction timing between different processors (I ran my tests on a Turion64 powered laptop btw).

    Beyond indicating that the eval overhead is small enough to be discounted in most practical contexts, the benchmark really doesn't tell us very much - except that you can't trust benchmarks very much for this sort of fine grain comparison. The important thing to note is that the eval costs much less than 1 micro-second.


    Perl is environmentally friendly - it saves trees