in reply to Re: Performance optimization question
in thread Performance optimization question
If you want it really fast get rid of the braces as well:
my @arr1 = grep /reg exp/, split /\|/, $string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Performance optimization question
by BrowserUk (Patriarch) on Apr 03, 2008 at 01:20 UTC | |
Yes. I forget how much difference that can make. Though joost's idea (with several modifications) works out fastest:
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
by jwkrahn (Abbot) on Apr 03, 2008 at 03:41 UTC | |
I get slightly different results: YMMV :-) | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Apr 03, 2008 at 04:36 UTC | |
YMMV :-) It did :) If you add a hits counter as in my benchmark above, you'll see the reason why. Buk2 does not match anything at all (and fails slowly) in your benchmark:
And that intrigued me, until I noticed that you are not chomping your data. Once you chomp it, you'll find that Buk2 matches the same number as the others, and runs much (1100%) faster than grep:
Alternatively, just add /s to the regex in Buk2 in your benchmark, and it will also allow Buk2 to work, but it will only be 500% faster.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by vit (Friar) on Apr 03, 2008 at 02:06 UTC | |
| [reply] |