whereas the other two use AUTOLOAD to create the subs in their own package space and then &goto them...every time they are used.
Eh, no. The first time they are used AUTOLOAD creates them and &gotos in them. The second time, the sub is there and the sub is called.

The difference is that Errno defines all the subs at compile time - they are empty prototyped subs returning a single value - and are hence are being constant folded at compile time. If you use EAGAIN, Perl will substitute the appropriate value at compile time - which avoids all the overhead of calling a subroutine at run time.

The benchmark is biased towards heavy use of constants. A typical program will only use a few constants, and only a few times in a program. That means that if you'd export a lot of constants the way Errno does, you pay a heavier price at compile time, regardless how often, and how many constants you use. Fcntl however avoids the costs of compiling all the subs you aren't going to use - but the price of using a constant goes up.

Perl --((8:>*

In reply to Re^2: Slow constants by Perl Mouse
in thread Slow constants by powerman

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.