Created
July 5, 2018 11:19
-
-
Save fujiwara/d879bb48424bc902619ebe1dd2c2ffcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.12.0; | |
use Benchmark qw/:all/; | |
my @src = 1 .. 1000; | |
cmpthese 0, { | |
push => sub { | |
my @dest; | |
for (@src) { | |
push @dest, $_; | |
} | |
}, | |
map => sub { | |
my @dest = map { $_ } @src; | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ perl -v | |
This is perl 5, version 26, subversion 0 (v5.26.0) built for darwin-2level | |
(with 1 registered patch, see perl -V for more detail) | |
Copyright 1987-2017, Larry Wall | |
Perl may be copied only under the terms of either the Artistic License or the | |
GNU General Public License, which may be found in the Perl 5 source kit. | |
Complete documentation for Perl, including FAQ lists, should be found on | |
this system using "man perl" or "perldoc perl". If you have access to the | |
Internet, point your browser at http://www.perl.org/, the Perl Home Page. | |
$ perl b.pl | |
Rate push map | |
push 14034/s -- -1% | |
map 14175/s 1% -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment