Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
nowadays it's much faster to use substr
I re-ran your benchmark on Linux 2.6.9 i686, perl v5.8.5 built for i386-linux-thread-multi. The difference was much less than what you encountered.
$ perl -w 666965.pl Benchmark: running substr, vec for at least 60 CPU seconds... substr: 67 wallclock secs (60.69 usr + 0.03 sys = 60.72 CPU) @ 0 +.58/s (n=35) vec: 66 wallclock secs (61.33 usr + 0.04 sys = 61.37 CPU) @ 0 +.54/s (n=33) s/iter vec substr vec 1.86 -- -7% substr 1.73 7% --
On Linux 2.6.22-10-386 i686, perl v5.10.0 (different hardware than above):
Benchmark: running substr, vec for at least 60 CPU seconds... substr: 62 wallclock secs (61.69 usr + 0.05 sys = 61.74 CPU) @ 0 +.44/s (n=27) vec: 61 wallclock secs (60.81 usr + 0.05 sys = 60.86 CPU) @ 0 +.39/s (n=24) s/iter vec substr vec 2.54 -- -10% substr 2.29 11% --
Update Mon Feb 11 12:13:38 CET 2008: Added perl 5.10 benchmark on lodin's request.
--
Andreas

In reply to Re^3: To Findout Prime number by andreas1234567
in thread To Findout Prime number by babug_prg

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (7)
    As of 2014-07-12 02:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (238 votes), past polls