目次 †
内容 †
まとめ †
追記 †
- Twitterとブログでコメントをいただきました。
- お礼リンク
検証したスクリプト †
#!/usr/bin/perl -w
use strict;
use Benchmark;
use Perl6::Slurp;
timethese(
5,
{ "Slurp" => q{
my $indexFile = "./big_file.txt";
my @array = slurp ( $indexFile, { chomp => 1 } );;
},
"mapChomp1" => q{
my $indexFile = "./big_file.txt";
my @array;
open( my $fh, $indexFile ) || die( "can't open index file: $!" );
map { chomp; push( @array, $_ ); } <$fh>;
close $fh;
},
"mapChomp2" => q{
my $indexFile = "./big_file.txt";
open( my $fh, $indexFile ) || die( "can't open index file: $!" );
my @array = map { chomp; $_; } <$fh>;
close $fh;
},
"mapChomp3" => q{
my $indexFile = "./big_file.txt";
open( my $fh, $indexFile ) || die( "can't open index file: $!" );
my @array = map { local $/; chomp; $_; } <$fh>;
close $fh;
},
}
);