Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 { ... }

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!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://760205]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-09-23 08:32 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (272 votes). Check out past polls.