Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

There are still plenty more ways to skin that cat :)

Why subtract and add; when you can just subtract. And why compare to zero when it is unnecessary:

#! perl use strict; use warnings; use Benchmark qw( cmpthese ); my $n = 1e6; my $foreach_loop_total = 0; my $c_for_loop_total = 0; my $while_loop_total = 0; my $while_loop_total2 = 0; cmpthese 100, { foreach_loop => \&foreach_loop, c_for_loop => \&c_for_loop, while_loop => \&while_loop, while_loop2 => \&while_loop2, }; print "\$foreach_loop_total = $foreach_loop_total\n"; print "\$c_for_loop_total = $c_for_loop_total\n"; print "\$while_loop_total = $while_loop_total\n"; print "\$while_loop_total2 = $while_loop_total2\n"; sub foreach_loop { $foreach_loop_total -= $_ for -$n .. 0; } sub c_for_loop { for (my $j = $n; $j >= 0; --$j) { $c_for_loop_total += $j; } } sub while_loop { my $n = $n; $while_loop_total += $n-- while $n; } sub while_loop2 { use integer; my $n = $n; $while_loop_total2 += $n-- while $n; } __END__ C:\test>junk Rate c_for_loop while_loop while_loop2 foreach_loo +p c_for_loop 4.94/s -- -22% -39% -44 +% while_loop 6.31/s 28% -- -22% -28 +% while_loop2 8.07/s 63% 28% -- -8 +% foreach_loop 8.76/s 77% 39% 8% - +- $foreach_loop_total = 50000050000000 $c_for_loop_total = 50000050000000 $while_loop_total = 50000050000000 $while_loop_total2 = 50000050000000

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^4: counting backward by BrowserUk
in thread counting backward by ag4ve

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 pondering the Monastery: (11)
    As of 2014-07-28 07:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (193 votes), past polls