Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Re: RegExps, Prematch and Postmatch without efficiency penalty

by bart (Canon)
on Sep 14, 2003 at 16:00 UTC ( [id://291412]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: RegExps, Prematch and Postmatch without efficiency penalty
in thread RegExps, Prematch and Postmatch without efficiency penalty

You have a benchmark problem.

You see, the most vile aspect about $`, $& and $' is the fact that they affect every single regexp in your script or any module used. So if you benchmark it against other approaches that also use regular expressions, you'll slow them down, too. Conclusion: if you want to compare approaches, you should do benchmark them in separate scripts.

You should also check out how speed compares between matches, especially on extremely long strings, with and without one of ($`, $&, $') being mentioned anywhere in your script. Because it's there that it matters, not where you actually make use of them, but everywhere else.

Replies are listed 'Best First'.
Re: Re: Re: Re: RegExps, Prematch and Postmatch without efficiency penalty
by liz (Monsignor) on Sep 14, 2003 at 16:27 UTC
    ...you should do benchmark them in separate scripts.

    This is similar to the problem I had trying to benchmark the memory footprint of threaded applications. See Benchmark::Thread::Size for an example of how I embedded scripts within scripts to get a clean memory benchmark. I think a similar (probably simpler) approach could be taken to benchmark alternate approaches to $`, $& and $'.

    Liz

      for an example of how I embedded scripts within scripts to get a clean memory benchmark.

      I started work on a generic tool to do this as part of my OO::Benchmark stuff. Never got around to finishing it though.


      ---
      demerphq

      <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found