saintmike has asked for the wisdom of the Perl Monks concerning the following question:
Given that PerlIO::via::MD5 uses Digest::MD5 under the hood, this is really surprising. Is this just a bad example? Also, if you have examples on how perlIO significantly improved the performance of a task or made your life easier programming it, I'd like to hear about it.perlio: 1 wallclock secs ( 1.04 usr + 0.07 sys = 1.11 CPU) @ 62 +.16/s (n=69) regular: 1 wallclock secs ( 0.92 usr + 0.20 sys = 1.12 CPU) @ 19 +4.64/s (n=218)
Here's the code for the benchmark, the file examined was 500K in size:
use PerlIO::via::MD5; use Digest::MD5 qw(md5_hex); use Benchmark qw(:all); my $file = "somebigfile.dat"; timethese(-1, { perlio => \&perlio, regular => \®ular, }); sub perlio { open(my $in,"<:via(MD5)", $file) or die "Can't open file for digesting: $!\n"; my $digest = <$in>; close $in; return $digest; } sub regular { local($/) = undef; open FILE, $file or die "Can't open file for digesting: $!\n"; my $data = <FILE>; close FILE; return md5_hex($data); }
|
|---|