Skip to content

Instantly share code, notes, and snippets.

@karupanerura
Created April 15, 2011 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karupanerura/921220 to your computer and use it in GitHub Desktop.
Save karupanerura/921220 to your computer and use it in GitHub Desktop.
Compress::LZO vs Compress::Zlib
use common::sense;
use Benchmark qw(timethese cmpthese);
use Compress::LZO;
use Compress::Zlib;
my $data = 'data' x 1000;
cmpthese timethese(500000, +{
lzo => sub{
my $comp = Compress::LZO::compress($data);
my $decomp = Compress::LZO::decompress($comp);
die('unmutch!') unless($data eq $decomp);
},
gzip => sub{
my $comp = Compress::Zlib::memGzip($data);
my $decomp = Compress::Zlib::memGunzip($comp);
die('unmutch!') unless($data eq $decomp);
}
});
# Benchmark: timing 500000 iterations of gzip, lzo...
# gzip: 541 wallclock secs (539.11 usr + 0.96 sys = 540.07 CPU) @ 925.81/s (n=500000)
# lzo: 9 wallclock secs ( 9.95 usr + 0.00 sys = 9.95 CPU) @ 50235.48/s (n=500000)
# Rate gzip lzo
# gzip 926/s -- -98%
# lzo 50235/s 5326% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment