I have put systematically my in the foreach (or in the smallest possible scope), and guess what 'for my' is actually consistently slower in case B. Somehow it surprised me :(

% stephan@labaule (/home/stephan) % % for _i in {1..5} > do > echo ===$_i==== > perl -W perf_test_allmy.px > echo --- > perl -W perf_test.px > done ===1==== Section A took 1.7020 CPU seconds Section B took 3.9560 CPU seconds Section A took 1.7330 CPU seconds Section B took 3.9660 CPU seconds --- Section A took 1.7020 CPU seconds Section B took 3.6850 CPU seconds Section A took 1.7420 CPU seconds Section B took 3.7760 CPU seconds ===2==== Section A took 1.7220 CPU seconds Section B took 4.0160 CPU seconds Section A took 1.7030 CPU seconds Section B took 4.0860 CPU seconds --- Section A took 1.7220 CPU seconds Section B took 3.7850 CPU seconds Section A took 1.7230 CPU seconds Section B took 3.6750 CPU seconds ===3==== Section A took 1.7120 CPU seconds Section B took 4.0960 CPU seconds Section A took 1.7220 CPU seconds Section B took 4.0460 CPU seconds --- Section A took 1.7320 CPU seconds Section B took 3.5250 CPU seconds Section A took 1.7220 CPU seconds Section B took 3.6450 CPU seconds ===4==== Section A took 1.7020 CPU seconds Section B took 4.1260 CPU seconds Section A took 1.7120 CPU seconds Section B took 3.9360 CPU seconds --- Section A took 1.7020 CPU seconds Section B took 3.8560 CPU seconds Section A took 1.7430 CPU seconds Section B took 3.6350 CPU seconds ===5==== Section A took 1.7020 CPU seconds Section B took 4.1560 CPU seconds Section A took 1.7120 CPU seconds Section B took 3.9760 CPU seconds --- Section A took 1.7220 CPU seconds Section B took 3.7350 CPU seconds Section A took 1.7330 CPU seconds Section B took 3.5850 CPU seconds
hth --stephan

In reply to Re: Garbage collection problem?? by sgt
in thread Garbage collection problem?? by tcarmeli

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.