in reply to Performance optimization question
A casual test showed a > 40% improvement by omitting the intermediate array:
my @arr1 = grep { /reg exp/ } split /\|/, $string; Rate orig A orig 232/s -- -30% A 331/s 43% --
And if the lack of mys and the need to set the length of the array in your code indicates you are using globals instead of lexicals, note that lexicals are usually a few percent faster.
A lot will depend upon how long the string is, how many elements it splits into, the complexity of /reg exp/, and the proportion of elements beig excluded. More info might yield better responses.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Performance optimization question
by jwkrahn (Abbot) on Apr 03, 2008 at 00:58 UTC | |
by BrowserUk (Patriarch) on Apr 03, 2008 at 01:20 UTC | |
by jwkrahn (Abbot) on Apr 03, 2008 at 03:41 UTC | |
by BrowserUk (Patriarch) on Apr 03, 2008 at 04:36 UTC | |
by vit (Friar) on Apr 03, 2008 at 02:06 UTC |