Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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
Replies are listed 'Best First'.
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: (6)
As of 2015-07-30 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls