Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: elsif chain vs. dispatch

by Burak (Chaplain)
on Apr 26, 2009 at 22:19 UTC ( #760205=note: print w/ replies, xml ) Need Help??


in reply to elsif chain vs. dispatch

Your example is not practical. Dispatch tables are usually defined once outside the code that runs it. I suggest creating a test code like:

my %dispatch; sub elsifchain { ... } sub dispatch { ... }


Comment on Re: elsif chain vs. dispatch
Download Code
Re^2: elsif chain vs. dispatch
by moritz (Cardinal) on Apr 26, 2009 at 22:28 UTC
    That's a good point - the dispatch table is created on every invocation, the elsif code variant is only compiled once. The second point is that the split calls actually obscure the test results, not clarify them.

    So what I did was to change all the alternatives to return a literal 'A' instead, and to build the dispatch table only once. That's the result:

    Rate elsif dispatch elsif 252062/s -- -73% dispatch 927942/s 268% --
      I knew I was doing something dumb. Thanks!

      SSF

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://760205]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-08-02 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls