Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: elsif chain vs. dispatch

by Burak (Chaplain)
on Apr 26, 2009 at 22:19 UTC ( [id://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 { ... }

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://760205]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-23 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found