Skip to content

Instantly share code, notes, and snippets.

@nekokak
Created April 4, 2011 07:12
Show Gist options
  • Save nekokak/901239 to your computer and use it in GitHub Desktop.
Save nekokak/901239 to your computer and use it in GitHub Desktop.
#! /usr/bin/perl
use strict;
use warnings;
use Benchmark qw/cmpthese/;
cmpthese(500000, {
'push' => sub {
my @array = (1 .. 10);
my @array2 = (1 .. 10);
push(@array, @array2);
},
'join' => sub {
my @array = (1 .. 10);
my @array2 = (1 .. 10);
@array = (@array, @array2);
}
});
__END__
$ perl ./array.pl
Rate join push
join 132275/s -- -35%
push 204082/s 54% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment