Which version of perl are you using?

5.005_03 seems to have a really slow tr///, that actually is slower than s/// (singe celeron 466)
Benchmark: timing 250000 iterations of one, two... one: 1 wallclock secs ( 0.83 usr + 0.00 sys = 0.83 CPU) two: 1 wallclock secs ( 0.74 usr + 0.00 sys = 0.74 CPU) Benchmark: timing 2000000 iterations of one, two... one: 7 wallclock secs ( 6.71 usr + 0.00 sys = 6.71 CPU) two: 6 wallclock secs ( 5.93 usr + 0.00 sys = 5.93 CPU)

However, 5.6.1 (on a dual p3 800) tr seems to be almost twice as fast.
Benchmark: timing 250000 iterations of one, two... one: 1 wallclock secs ( 0.26 usr + 0.00 sys = 0.26 CPU) @ 96 +1538.46/s (n=250000) (warning: too few iterations for a reliable count) two: 1 wallclock secs ( 0.46 usr + 0.00 sys = 0.46 CPU) @ 54 +3478.26/s (n=250000) Benchmark: timing 2000000 iterations of one, two... one: 2 wallclock secs ( 2.06 usr + 0.00 sys = 2.06 CPU) @ 97 +0873.79/s (n=2000000) two: 4 wallclock secs ( 3.68 usr + 0.00 sys = 3.68 CPU) @ 54 +3478.26/s (n=2000000)

I don't know too much about the tr/// and s/// code, but it looks like someone went and optimized tr/// between 5.005 and 5.6.1. (Would someone who knows (japhy?) please comment on this?)

In reply to Re: Re: Re: transliterate by dondelelcaro
in thread transliterate by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.