in reply to Does eval cause that much of a performance hit?

I would much prefer to put the 15 tests in a hash, iterate over the keys and do that instead of writing 45 lines of .... plain easier to add new tests if need be.

It appears your reasons are aesthetic, can you elaborate on your reasons?

Should I really be concerned about performance hits?

Maybe. The rule of thumb is if it seems slow, or you need to run it often, try to make it faster.

Does eval REALLY cause that much of a performance issue?

:) Can you quantify REALLY and that much ? eval EXPR is parsed and executed as if it were a little Perl program. So instead of parsing/executing one Perl program, you have one plus X many little ones. 1+X is slower than 1 :)

  • Comment on Re: Does eval cause that much of a performance hit?

Replies are listed 'Best First'.
Re^2: Does eval cause that much of a performance hit?
by sherab (Scribe) on May 06, 2009 at 03:49 UTC
    It appears your reasons are aesthetic, can you elaborate on your reasons?

    If preferring not having to read 45 lines of if{} in favor of much fewer then yes it is aesthetic. It just seems that 45 lines of if {} is just unnecessary and redundant. If there are 15 tests and I can see all 15 without having to page down then all the better.

    Maybe. The rule of thumb is if it seems slow, or you need to run it often, try to make it faster.
    It would take official benchmarking to determine that. It's negligable in real terms IMHO.

    :) Can you quantify REALLY and that much ? eval EXPR is parsed and executed as if it were a little Perl program. So instead of parsing/executing one Perl program, you have one plus X many little ones. 1+X is slower than 1 :)
    Ah now we're getting to a golden nugget. Seeing that eval EXPR is parsed and executed as if it were a little program and then having that eval to happen 15 times does answer my question to a degree although I believe the answer is going to involve a benchmark every time I want to make the point that using eval is negligable.

    I appreciate your input on this.
    Sherab
      It just seems that 45 lines of if {} is just unnecessary and redundant

      How? Instead of typing if(code){code} you type q{code},q{code} (or 'code' => 'code') just so it would fit on one page? That is very superficial, and I dare say, juvenile. Much much better idea would be to limit file size to what fits on one screen, say 30 lines ...