in reply to Does the reference of a scalar more efficient than scalar?
Result:use strict; use warnings; use Benchmark qw(cmpthese); my $long_string = 'aaaaaaaaaaaaaaaaaaaaaaaa' x 1000000; my $destination; sub return_scalar { return $long_string } sub return_ref { return \$long_string } cmpthese( -1, { 'scalar' => sub { $destination = return_scalar() }, 'ref' => sub { $destination = return_ref () }, } );
Rate scalar ref scalar 22.2/s -- -100% ref 1612824/s 7250890% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Does the reference of a scalar more efficient than scalar?
by Tanktalus (Canon) on Dec 11, 2008 at 17:02 UTC |