I then bumped up the string size so it went in 10k increments rather than 1k, and reduced the loop count. There's a weird effect occuring when the string size switches between 130k -> 140k.sub by_alias { $_[0] =~ s/\s+//; } sub by_alias2 { for ($_[0]) { s/\s+//; } } sub by_alias3 { ${\$_[0]} =~ s/\s+//; } sub by_ref { ${ $_[0] } =~ s/\s+//; } sub by_ref2 { for (${ $_[0] }) { s/\s+//; } }
That's just bizarre. It seems for strings < 130k, something strange is occuring with @_ aliasing, and for strings > 130k, for () aliasing and references are going haywire. Very odd indeed. This is debian perl, v5.8.8 built for i486-linux-gnu-thread-multiLength of string: 130000 Rate alias ref2 alias2 ref alias3 alias 17544/s -- -67% -67% -68% -68% ref2 52632/s 200% -- -0% -5% -5% alias2 52632/s 200% 0% -- -5% -5% ref 55556/s 217% 6% 6% -- 0% alias3 55556/s 217% 6% 6% 0% -- Length of string: 140000 Rate alias3 alias2 ref2 ref alias alias3 1376/s -- -0% -0% -0% -92% alias2 1377/s 0% -- -0% -0% -92% ref2 1379/s 0% 0% -- -0% -92% ref 1381/s 0% 0% 0% -- -92% alias 16393/s 1092% 1090% 1089% 1087% --
In reply to Re: Pass by ref vs alias : why does scalar size matter?
by Anonymous Monk
in thread Pass by ref vs alias : why does scalar size matter?
by clinton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |