Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. Regular Expressions > Item 41. Benchmark your regular expressions

Item 41. Benchmark your regular expressions

As with many other things in Perl, one of the best ways to determine how to make a pattern match run quickly is to write alternative implementations and compare them to one another.

Use the Benchmark module to see how much of a difference capture-free parentheses (Item 32) can really make. Here’s a small program to test a regular expression that extracts the requesting host from the line of an Apache access_log in the common log format, which looks like:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint