Trying to benchmark SLURP versus other forms of Perl code
Get error "Substitution loop at c:/strawberry/perl/vendor/lib/File/Slurp.pm line 254
Following code works well to 600MB but over this size error occurs in step 3.
#!usr/bin/perl use strict; use File::Slurp qw( :all); use Time::HiRes qw(gettimeofday tv_interval); # get arguments for process my $tmv0 = [gettimeofday]; my $fl_in = $ARGV[0]; # reading records... step 1 open my $in_fh, '<', $fl_in or die $!; my $s1=<$in_fh>; print "$s1 from $fl_in \n"; my $numin=0; while (<$in_fh>) { $numin++; } close $in_fh; my $tmv1 = tv_interval($tmv0,[gettimeofday]); print " Test Step 1 Found $numin records at $tmv1\n"; ### ### now using whole string... step 2 ### open my $in_fh, '<', $fl_in or die $!; my $text_file = do { local $/; <$in_fh> }; close $in_fh; my $tmv2 = tv_interval($tmv0,[gettimeofday])-$tmv1; my $lenstr=length($text_file); print " Test Step 2 Found $lenstr bytes in $tmv2 seconds\n"; ## ## Now slurp... step 3 ## $numin=0; $text_file = read_file($fl_in); $lenstr=length($text_file); my $tmv3 = tv_interval($tmv0,[gettimeofday])-$tmv1-$tmv2; print " Test Step 3 Found $lenstr bytes in $tmv3 seconds\n";
In reply to SLURP Error by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |