Gzip::Faster - gzip and gunzip, without the fuss
use Gzip::Faster; my $gzipped = gzip ($input); my $roundtrip = gunzip ($gzipped); # $roundtrip is the same as $input
This module compresses to and decompresses from the gzip format.
my $zipped = gzip ($stuff);
Compress $stuff.
$stuff
my $stuff = gunzip ($zipped);
Uncompress $zipped. This will cause a fatal error if $zipped is not compressed.
$zipped
This section compares the performance of Gzip::Faster with IO::Compress::Gzip and IO::Uncompress::Gunzip. Here is a comparison of a round-trip:
Rate IO::Compress::Gzip Gzip::Faster IO::Compress::Gzip 1199/s -- -91% Gzip::Faster 12800/s 968% --
Here is a comparison of gzip (compression) only:
Rate IO::Compress::Gzip Gzip::Faster IO::Compress::Gzip 2355/s -- -87% Gzip::Faster 17582/s 647% --
Here is a comparison of gunzip (decompression) only:
Rate IO::Uncompress::Gunzip Gzip::Faster IO::Uncompress::Gunzip 2739/s -- -96% Gzip::Faster 67368/s 2360% --
The test file is in "examples/benchmark.pl" in the distribution.
There is also a module called Compress::Raw::Zlib which offers access to zlib itself. It may offer improved performance, however I have not figured out what it does yet. Its documented way of making a gzip compressed object returns something I cannot understand so I was unable to include it in the benchmark.
The module includes functionality to round-trip various Perl flags. I applied this to preserving Perl's "utf8" flag. However, the mechanism I used trips a browser bug in the Firefox web browser where it produces a content encoding error message. Thus this functionality is disabled.
Ben Bullock <bkb@cpan.org>. Copyright (C) 2014 Ben Bullock. This software may be used, modified, distributed under the same licence as Perl itself.
To install Gzip::Faster, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gzip::Faster
CPAN shell
perl -MCPAN -e shell install Gzip::Faster
For more information on module installation, please visit the detailed CPAN module installation guide.