On a moderately loaded Solaris machine, alias keeps ahead of ref, but it seems that the string length dominates the speed, as both rates get lower and closer to each other with no signs of one overtaking the other:

Length of string: 1000 Rate ref alias alias 141243/s 58% -- ref 89366/s -- -37% ... Length of string: 10000 Rate ref alias alias 45496/s 19% -- ref 38388/s -- -16% ... Length of string: 20000 Rate ref alias alias 25947/s 12% -- ref 23186/s -- -11%

This is for

This is perl, v5.8.4 built for sun4-solaris-64int (with 27 registered patches, see perl -V for more detail)

On a different machine, also moderately loaded, I see practically the same, also with alias keeping (barely) ahead of ref as the string size increases:

Length of string: 1000 Rate ref alias alias 404858/s 115% -- ref 187970/s -- -54% Length of string: 2000 Rate ref alias alias 367647/s 87% -- ref 196850/s -- -46% ... Length of string: 10000 Rate ref alias alias 220751/s 24% -- ref 177936/s -- -19% ... Length of string: 18000 Rate ref alias alias 168067/s 2% -- ref 165563/s -- -1% Length of string: 19000 Rate alias ref ref 162866/s 1% -- alias 161551/s -- -1% Length of string: 20000 Rate alias ref ref 162602/s 2% -- alias 160000/s -- -2%

Here, the decrease in repetitions is more dramatic for alias as the string length increases, which I interpret as the runtime overhead of alias being really minuscule compared to the overhead of the other operations performed.

This is on a HP-UX machine with Intel architecture:

This is perl, v5.8.8 built for IA64.ARCHREV_0-thread-multi (with 33 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 817.1 [268662] provided by ActiveState http://www.ActiveS +tate.com Built Sep 19 2006 13:53:03

Interestingly, trying this with Strawberry 5.10.0, I see your reversal (Intel architecture):

Rate ref alias ref 258065/s -- -46% alias 477783/s 85% -- ... Length of string: 10000 Rate alias ref alias 123533/s -- -25% ref 164528/s 33% -- ... Length of string: 20000 Rate alias ref alias 65509/s -- -42% ref 112867/s 72% --

This is for

This is perl, v5.10.0 built for MSWin32-x86-multi-thread

Trying on the same machine with Strawberry 5.8.8, I get

Length of string: 1000 Rate ref alias alias 511771/s 53% -- ref 335121/s -- -35% Length of string: 2000 Rate ref alias alias 383289/s 28% -- ref 299043/s -- -22% Length of string: 3000 Rate ref alias alias 318471/s 14% -- ref 279486/s -- -12% Length of string: 4000 Rate ref alias ref 256016/s -- -2% alias 262329/s 2% -- Length of string: 5000 Rate alias ref alias 219154/s -- -7% ref 236183/s 8% -- ... Length of string: 10000 Rate alias ref alias 121448/s -- -29% ref 170707/s 41% -- ... Length of string: 20000 Rate alias ref alias 67801/s -- -39% ref 111694/s 65% --

This was with:

This is perl, v5.8.8 built for MSWin32-x86-multi-thread

So, at least judging from the limited set of versions and platforms, things point in the direction of Windows or MSVC to be responsible for the dramatic slowdown although I'm at a loss as to what part might be causing the slowdown.


In reply to Re: Pass by ref vs alias : why does scalar size matter? by Corion
in thread Pass by ref vs alias : why does scalar size matter? by clinton

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.