Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:
Beware premature optimization - dragons be hiding ahead.
Now I just happen to have be writing a script that reused the same 5 lines of code several times within a loop, so I made it a sub. This particular loop goes through millions of iterations. Now the difference in run times between using a sub versus copying and pasting the code was under 1 minute, but I wondered if there was a way to get the outcome of copying and pasting, but keep the maintainability of a sub.
I think in Perl 6 (I am oblivious), that you will be able to do just this (if the conditions are right). I asked in the CB and I got various suggestions. I was going to let it drop, but bart prompted me to post here if for no other reason than to have a node to Super Search on when someone else asks the same question.
The suggestions I have heard so far:
If someone knows how to do this without a lot of work - then please divulge. If there is no easy answer, then there is no need to pursue it. If you need that much speed - Perl probably isn't the right solution in the first place ;-)
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inline subs?
by broquaint (Abbot) on May 02, 2003 at 01:12 UTC | |
by Limbic~Region (Chancellor) on May 02, 2003 at 01:19 UTC | |
by dragonchild (Archbishop) on May 02, 2003 at 13:36 UTC | |
by broquaint (Abbot) on May 02, 2003 at 15:11 UTC | |
|
Re: Inline subs?
by Joost (Canon) on May 02, 2003 at 12:20 UTC | |
|
Re: Inline subs?
by PodMaster (Abbot) on May 02, 2003 at 07:15 UTC | |
|
Re: Inline subs?
by Improv (Pilgrim) on May 02, 2003 at 02:16 UTC | |
|
Re: Inline subs?
by nadadogg (Acolyte) on May 02, 2003 at 18:44 UTC | |
by chromatic (Archbishop) on May 02, 2003 at 19:19 UTC |