in reply to Re: Badly need to call a function...:-)
in thread Badly need to call a function...:-)

Dear pedant and all gurus: I am very pleased with your attention, didn't expect anything like that.
regarding (1==1): gentlement, c'mon, I only wanted to "kind-of-preserve" the "if" statement without exposing the business logic.
Greately surprised that this sort of things can have a performance implications. From the other hand, curious: can these tiny details have an impact on real-world stuff?
  • Comment on Re^2: Badly need to call a function...:-)

Replies are listed 'Best First'.
Re^3: Badly need to call a function...:-)
by eibwen (Friar) on Apr 17, 2005 at 18:05 UTC
    The performance implication depends on your implementation. If it's a critical application, particularly one that iterates significantly, the difference may be significant. Conversely, if the code isn't iterative, or only sees a few iterations, the difference is likely neglible. Given this understanding, you may want to benchmark the codes using the Benchmark module:

    use Benchmark qw(cmpthese); @data = (1,2,3,4); # the values that would have been in @_ my $minCPUsec = 15; cmpthese(-$minCPUsec, { with => \&sub_with_ifs, without => \&sub_without_ifs });

    And change @_ in the referenced subs to @data.

    Additionally, you may be interested in the Benchmarking Your Code tutorial, but I'd recommend using cmpthese instead of timethese.