[sf-perl] Can't figure this one out

Kevin Frost biztos at mac.com
Wed Mar 5 21:58:30 PST 2008


There is also a Switch module if you miss your case/esac.

Haven't used it in years and never benchmarked it, and now I would  
rather lean towards a dispatch model, but IIRC it did its job well.

  -- frosty

(via iPhone)


On Mar 5, 2008, at 7:51 PM, Joe Brenner <doom at kzsu.stanford.edu> wrote:

>
> Joe Brenner <doom at kzsu.stanford.edu> wrote:
>> Steve Fink <sphink at gmail.com> wrote:
>>>>> By the way
>>>>>
>>>>> if ($action =~ /start/i) {
>>>>>        &MainPage($q, \%p);
>>>>> } elsif ($action =~ /new|del|edt|save/i ) {
>>>>>
>>>>> {
>>>>>
>>>>> seems better to me
>>>>
>>>> It's more compact, but I bet it runs slower.  This might even be a
>>>> case where performance matters (i.e. if the cgi script sees a lot  
>>>> of
>>>> traffic).
>>>
>>> I'll take that bet. I bet the all-regex version is faster.  
>>> Especially
>>> on newer versions of Perl that have the trie optimization, but even
>>> without that I'd guess that it's faster.
>>
>> And you may already be a winner.
>>
>> I did a quickie benchmark and it looks like the regexp alternation
>> version is around 17% faster even in the "worst" cases (running on
>> perl v5.8.7).  I've seen some regexps with heavy reliance on  
>> alternation
>> that ran pretty slow, but this isn't one of them (and that was
>> a while back in any case).
>
> Funny thing though... just for the hell of it I ran the same code  
> under
> perl 5.10 (really, 5.9.5), and the results came out the other way,  
> with
> the alternation regexp being a bit slower (~25%) than the stack of
> boolean ors.  Weird.
>
> No, I take it back, it's not that weird: the Debian/Ubuntu version of
> 5.8.7 was built very differently from my 5.9.5 build:
>
> perl 5.8.7:
>  Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT
>                        USE_64_BIT_ALL USE_LARGE_FILES
>                        PERL_IMPLICIT_CONTEXT
>
> perl 5.9.5:
>  Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
>                        USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES
>                        USE_PERLIO
>
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm


More information about the SanFrancisco-pm mailing list