public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#!/usr/bin/env perl
 
use strict;
use warnings;
 
use Benchmark qw(cmpthese);
 
cmpthese shift || -3, {
"shift" => sub {
my $arg = shift;
},
"array" => sub {
my($arg) = @_;
},
"1 element scalar" => sub {
my $arg = $_[0];
},
"1 element list" => sub {
my($arg) = $_[0];
},
};
 
 
__DATA__
NOTE: This is benchmarking a subroutine being passed NO arguments.
It could all change if it were passed arguments.
Also these numbers are fairly volatile, changing as much as 20% between runs.
Not surprising as we're benchmarking such a fast operation.
 
5.10.1 no threads
Rate array 1 element list shift 1 element scalar
array 11904762/s -- -15% -35% -48%
1 element list 13986014/s 17% -- -23% -39%
shift 18181818/s 53% 30% -- -21%
1 element scalar 22988506/s 93% 64% 26% --
 
5.12.4 with threads
Rate array 1 element list shift 1 element scalar
array 11764706/s -- -5% -28% -45%
1 element list 12422360/s 6% -- -24% -42%
shift 16260163/s 38% 31% -- -24%
1 element scalar 21276596/s 81% 71% 31% --
 
5.14.1 with threads
Rate array 1 element list shift 1 element scalar
array 9433962/s -- -17% -36% -49%
1 element list 11363636/s 20% -- -23% -38%
shift 14705882/s 56% 29% -- -20%
1 element scalar 18348624/s 94% 61% 25% --
 
5.16.1 no threads
Rate array 1 element list 1 element scalar shift
array 10638298/s -- -13% -56% -61%
1 element list 12195122/s 15% -- -49% -55%
1 element scalar 24096386/s 127% 98% -- -11%
shift 27027027/s 154% 122% 12% --

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.