in reply to Re: counting regex hits Benchamark
in thread counting regex hits

I know that it is well-known that tr is faster than m//

Except when it is not.

Quite impressive difference, isn't it?
No. The difference is 1/18982.5th of second which isn't impressive at all. q-: The quotient looks impressive but benchmark has to go to a lot of work to be able to guess at that so you won't see a quotient anything close to that in practice.

Congratulations, you've now prematurely optimized this nano-operation.

I find that the difference is usually more indicative of the practical value of the optmization than the quotient.

                - tye (cheap philosophy shouldn't cost a lot)
  • Comment on Re^2: counting regex hits Benchamark (except)

Replies are listed 'Best First'.
Re: Re^2: counting regex hits Benchamark (except)
by Tomte (Priest) on Mar 19, 2003 at 07:38 UTC

    I know that it is well-known that tr is faster than m//
    Except when it is not.

    Point taken: I amend my original proposition with:
    if the problem is as simple as the OPs, that is if a simple transliteration is your goal, or a sideeffect of this transliteration, that you may as well use the transliteration operator seems to be a well known fact.

    :-)

    Congratulations, you've now prematurely optimized this nano-operation.

    Do not fall pray to false conclusions:
    I was interested in the abstract comparison of two nano-operations and in how to use Benchmark.pm myself, I didn't optimize anything, how could I? I don't have code lying around using any of these oprarators to actually count anything. So as this wasn't optimization, how could it be premature?;-p

    I find that the difference is usually more indicative of the practical value of the optmization than the quotient.

    this point taken again

    kind regards,
    tomte