Benchmark in Perl – replace

if you want to check whats the fastest way to replace a string in Perl you could use the Benchmark-Module.I compared 4 different ways  :

the result looks like:

Always check you sub results (Line 1-5) and make more test cases,

at the first case (Line 6) we see that for single character the best solution is to use regex.If you want to replace a longer string better use a C function.But in both cases its better to use the /o flag for regex to optimize, but then you cant interpolate a string in to the regex.And if you only want to replaxe use tr its the fastest.

4 thoughts on “Benchmark in Perl – replace”

  1. I’m really enjoying the design and layout of your blog. It’s a very
    easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to
    create your theme? Fantastic work!

    View Comment
  2. I got this website from my pal who shared with me regarding
    this web page and now this time I am browsing
    this web site and reading very informative articles at this place.

    View Comment
  3. Someone necessarily lend a hand to make seriously articles I would
    state. That is the very first time I frequented your web page and
    thus far? I surprised with the research you made to make this particular publish
    incredible. Fantastic process!

    View Comment
  4. I have been exploring for a little bit for any high-quality articles or weblog posts in this sort of area .
    Exploring in Yahoo I at last stumbled upon this site. Studying
    this information So i’m satisfied to show that I have an incredibly just right uncanny feeling I came upon exactly what I needed.
    I such a lot undoubtedly will make sure to don?t disregard this site and give it a look
    regularly.

    View Comment

Leave a Reply

Your email address will not be published.

seventeen + eleven =