In fairness, I should add that my original version is the slowest, by a fair margin (and gets much worse as the string gets longer). Adding `gapify' in danger's benchmark yields (with Perl 5.005_03):
Benchmark: running danger, gapify, japhy, each for at least 2 CPU seco +nds... danger: 3 wallclock secs ( 2.00 usr + 0.00 sys = 2.00 CPU) @ 66 +271.00/s (n=132542) gapify: 2 wallclock secs ( 2.37 usr + 0.00 sys = 2.37 CPU) @ 41 +536.06/s (n=98302) japhy: 2 wallclock secs ( 2.55 usr + 0.00 sys = 2.55 CPU) @ 55 +071.76/s (n=140433) Benchmark: running danger, gapify, japhy, each for at least 2 CPU seco +nds... danger: 3 wallclock secs ( 1.98 usr + 0.02 sys = 2.00 CPU) @ 31 +026.00/s (n=62052) gapify: 2 wallclock secs ( 2.07 usr + 0.00 sys = 2.07 CPU) @ 14 +864.03/s (n=30719) japhy: 2 wallclock secs ( 2.00 usr + 0.00 sys = 2.00 CPU) @ 23 +104.50/s (n=46209) Benchmark: running danger, gapify, japhy, each for at least 2 CPU seco +nds... danger: 2 wallclock secs ( 2.00 usr + 0.00 sys = 2.00 CPU) @ 19 +81.00/s (n=3962) gapify: 2 wallclock secs ( 2.03 usr + 0.00 sys = 2.03 CPU) @ 18 +7.87/s (n=382) japhy: 2 wallclock secs ( 2.08 usr + 0.00 sys = 2.08 CPU) @ 12 +27.84/s (n=2558)

In reply to Re: Re: Re: Re: Adding gaps to a sequence by ariels
in thread Adding gaps to a sequence by ariels

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.