Hi Monks,

I have these simple one liner tests in my CentOS 7 vps box

1a. test perl loop with $i=10 $ time perl -e 'for($i=0;$i<=10;$i++){}' real 0m0.003s user 0m0.000s sys 0m0.000s 1b. test PHP loop with $i=10 $ time php -r 'for($i=0;$i<=10;$i++){}' real 0m0.027s user 0m0.020s sys 0m0.004s in average test 1a and 1b, perl is 9x or 10x faster than PHP ------------------------------------------------------------ 2a. test perl loop with $i=10000 $ time perl -e 'for($i=0;$i<=10000;$i++){}' real 0m0.005s user 0m0.004s sys 0m0.000s 2b. test PHP loop with $i=10000 $ time php -r 'for($i=0;$i<=10000;$i++){}' real 0m0.027s user 0m0.024s sys 0m0.000s in test 2a and 2b, perl still much faster than PHP ------------------------------------------------------------ 3a. test perl loop with $i=1000000 $ time perl -e 'for($i=0;$i<=1000000;$i++){}' real 0m0.091s user 0m0.088s sys 0m0.000s 3b. test PHP loop with $i=1000000 $ time php -r 'for($i=0;$i<=1000000;$i++){}' real 0m0.045s user 0m0.044s sys 0m0.004s in test 3a and 3b, PHP already faster then perl ------------------------------------------------------------ now, use extreme loop number like all benchmark code in alioth benchmark game: 4a. test perl loop with $i=100000000 $ time perl -e 'for($i=0;$i<=100000000;$i++){}' real 0m7.310s user 0m7.304s sys 0m0.000s 4b. test PHP loop with $i=100000000 $ time php -r 'for($i=0;$i<=100000000;$i++){}' real 0m1.624s user 0m1.616s sys 0m0.004s in test 4a and 4b, PHP is much much faster then perl

I already try compare with java, node, and c and the result same as result above, more loop number make loop slower but not as extreme slower as perl

Is there any setting or ENV to make perl loop faster for big number like test above ?

thx,

In reply to perl process slower and slower when loop number increase 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.