Subject: | Performance of IO::Uncompress::Gunzip .. really bad. |
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin . "/../../lib/";
use IO::Uncompress::Gunzip;
use Tools::Timer;
Tools::Timer->timer("start gunzip");
for(my $i= 0;$i < 10; $i++){
open FH,"zcat $ARGV[0] |";
while(my $line = <FH>){
my $var = $line;
}
close(FH);
}
Tools::Timer->timer("stop gunzip");
Tools::Timer->timer("start IO::Uncompress");
for(my $i= 0;$i < 10; $i++){
my $fh = new IO::Uncompress::Gunzip($ARGV[0]);
while(my $line = <$fh>){
my $var = $line;
}
close($fh);
}
Tools::Timer->timer("stop IO::Uncompress");
Tools::Timer->print_result;
Produces.
imer: start gunzip - stop gunzip 7.708832s ( 5.2%)
timer: stop gunzip - start IO::Uncompress 0.000049s ( 0.0%)
timer: start IO::Uncompress - stop IO::Uncompress 141.507715s
(94.8%)
timer: Total timed 149.216596s
Sum.. zcat in a pipe it 20 times faster than IO::Uncompress ..
Jesper