The final outcome of that thread was to demonstrate that you don't even understand the difference between micro-optimizations and real optimizations. Which you demonstrate some more here.

So, whilst in the OPs target case, subroutine overhead is a red-herring, dismissing it completely as peanuts is a bad message in the wider scheme of things.

I didn't dismiss the sub overhead completely as peanuts. I concurred with dismissing the very specific case of 100k subroutine calls as peanuts (and then commented on how silly your "OMG! 400% faster, wow!" demonstration was).

Even if File::Find weren't accessing the file system, the idea of just eliminating subroutine call overhead would still be silly. The subroutines of File::Find aren't even close to as trivially tiny as they would need to be for removing subroutine calls to have a chance of being worthwhile.

Your own benchmark even makes that easy to see. You show that doing one useless thing (an addition) is 4 times faster than doing several useless things (an addition, a subroutine call, a 'my' declaration, copying a passed-in value, returning a copy of that value).

- tye        


In reply to Re^5: Efficiency: Recursive functions while de-subbing my program (arithmetic) by tye
in thread Efficiency: Recursive functions while de-subbing my program by Endless

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.