Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Benchmarks aren't everything

by zby (Vicar)
on Oct 24, 2005 at 12:07 UTC ( [id://502438]=note: print w/replies, xml ) Need Help??


in reply to Benchmarks aren't everything

It looks like the described technique is an example of Dynamic programming.

Replies are listed 'Best First'.
Re^2: Benchmarks aren't everything
by tilly (Archbishop) on Oct 24, 2005 at 18:45 UTC
    Thinking about it further, I think it is possible to implement this solution with less overhead. If your goal is merely to prevent disasters, then the right optimization is one which is fast in the common case and makes the bad case run, not one which tries to make the bad case fast as well.

    An example of how one might do that is have a flag in every RE node saying whether we are tracking positions in the string that we've been to. If we are, then have a linked list that you scan to find whether your current position has been reached yet. If you're not, then do nothing. Then insert code that once every large number of steps sets this bit in various nodes. (For instance the check might happen when you fail back to a second alternative - do that 10,000 times and then set the bit on your current node.)

    On fast regular expressions all you do is check a flag. On slow ones, you run a lot slower (a linked list is a lot of overhead), but at least you still run.

Re^2: Benchmarks aren't everything
by tilly (Archbishop) on Oct 24, 2005 at 12:46 UTC
    Yes, but the implementation is rather more efficient than a naive implementation of dynamic programming would be likely to be.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found