in reply to does a hash element as a loop parameter cause significant slowdown?

G'day misterperl,

Use Benchmark to check for "significant slowdown".

More generally, "perlperf - Perl Performance and Optimization Techniques" provides useful information.

Also be aware that Perl is being continually optimised: some code might be slower than other code for a particular Perl version; in a subsequent version there may be no difference.

If you post benchmark code and results, we'll be happy to discuss. You may also receive alternative code that you hadn't considered and may be better for your specific needs.

— Ken

  • Comment on Re: does a hash element as a loop parameter cause significant slowdown?

Replies are listed 'Best First'.
Re^2: does a hash element as a loop parameter cause significant slowdown?
by eyepopslikeamosquito (Archbishop) on Sep 10, 2023 at 01:23 UTC

    > Use Benchmark to check for "significant slowdown"

    Yes. I really like TheDamian's simple adage "Don't Optimize Code -- Benchmark It" - if you don't follow his advice, you'll probably end up with a fast slow program. :)

    Without good design, good algorithms, and complete understanding of the program's operation, your carefully optimized code will amount to one of mankind's least fruitful creations -- a fast slow program.

    -- Michael Abrash

    Correctness, simplicity and clarity come first ... so you shouldn't really consider optimizing that little piece of code until you've benchmarked the entire program and identified it as a chronic bottleneck.

    For an example of using Benchmark to compare different snippets of Perl code see: Re^3: looping efficiency (Benchmark Example)

    Updated: added Michael Abrash quote to clarify what I meant by a fast slow program. Added Correctness, simplicity and clarity paragraph.