use strict; use warnings; use Benchmark qw(cmpthese); for my $argCount (2, 10, 100) { my @args = (1 .. $argCount); print "\nFor $argCount elements:\n"; cmpthese (-1, { hashArg => sub { noCopy ({@args}) }, listArg => sub { noCopy ( @args) }, toList => sub { toList ( @args) }, toHash => sub { toHash ( @args) }, rtoHref => sub { rtoHref ({@args}) }, rtoHash => sub { rtoHash ({@args}) }, } ); } sub noCopy { } sub toList { my @args = @_ } sub toHash { my %hash = @_ } sub rtoHash { my %hash = %{$_[0]} } sub rtoHref { my ($hash) = @_ }