mscharrer has asked for the wisdom of the Perl Monks concerning the following question:
I was just wondering how expensive the use of eval { } is. The code is compiled at compile time with all other code and eval can use the return statement, so it might be similar overhead like using a sub function.
Is eval {} much more expensive in terms of runtime (or other terms) then with e.g. using a sub call? Not that both would have the same function - just as a reference point.
Would it be ok, e.g. reasonable fast, to have eval {} inside a for loop, to test for exceptions for every element, or is it recommended to use eval {} outside the loop to speed things up?
Thanks for your wisdom.
Martin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How expensive is eval { }?
by moritz (Cardinal) on Apr 17, 2008 at 09:12 UTC | |
by mscharrer (Hermit) on Apr 17, 2008 at 09:18 UTC | |
by moritz (Cardinal) on Apr 17, 2008 at 09:25 UTC | |
|
Re: How expensive is eval { }?
by GrandFather (Saint) on Apr 17, 2008 at 09:19 UTC | |
by moritz (Cardinal) on Apr 17, 2008 at 09:33 UTC | |
by GrandFather (Saint) on Apr 17, 2008 at 10:05 UTC | |
|
Re: How expensive is eval { }?
by dragonchild (Archbishop) on Apr 17, 2008 at 12:35 UTC | |
by mscharrer (Hermit) on Apr 17, 2008 at 13:47 UTC |