#! perl -slw use strict; use File::Slurp; use Benchmark qw[ cmpthese ]; print `wc -l $ARGV[ 0 ]`; open our $infile, '<', $ARGV[ 0 ] or die $!; our $I //= -1; cmpthese $I, { a=> q[ sysseek $infile, 0, 0; my @lines = read_file( $infile, chomp => 1 ); print 'a: ', scalar @lines if $I == 1; ], b=> q[ sysseek $infile, 0, 0; chomp( my @lines = <$infile> ); print 'b: ', scalar @lines if $I == 1; ], c=> q[ sysseek $infile, 0, 0; my @lines; $lines[ @lines ] = <$infile> until eof $infile; chomp @lines; print 'c: ', scalar @lines if $I == 1; ], }; __END__ C:\test>t-slurp -I=1 small.tsv 1000000 small.tsv a: 1000000 (warning: too few iterations for a reliable count) b: 1000000 (warning: too few iterations for a reliable count) c: 1000000 (warning: too few iterations for a reliable count) s/iter a b c a 257 -- -98% -98% b 4.94 5115% -- -16% c 4.14 6119% 19% -- C:\test>t-slurp -I=-1 small.tsv 1000000 small.tsv (warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) s/iter b a c b 4.88 -- -4% -100% a 4.69 4% -- -100% c 1.39e-006 350525381% 337007680% --