in reply to Re^2: Binary files
in thread Binary files
Leeeeeeeeeeeeeeeeeeeeets BENCHMARK!
Where "x" is 22Mb:use Benchmark qw(:all); + timethese( 100, { 'By File Size' => sub { open XLSFILE, "x"; my $xlsdata = do { local $/ = \-s (XLSFILE); <XLSFILE> }; }, 'Plain Slurp' => sub { open XLSFILE, "x"; my $xlsdata = do { local $/; <XLSFILE> }; + }, } );
It appears that using the file size is a nats cock faster, which is as I would expect as the traditional slurp will have to go looking for the end of the file.By File Size: 11 wallclock secs ( 7.54 usr + 3.11 sys = 10.65 CPU) @ + 9.39/s (n=100) Plain Slurp: 11 wallclock secs ( 8.50 usr + 2.95 sys = 11.45 CPU) @ +8.73/s (n=100)
/J\
|
|---|