#!/usr/bin/perl -w #use strict; use LWP::UserAgent; use Compress::Raw::Zlib; use Time::HiRes qw( usleep time ); sub callback { my $output; $z->inflate($_[0], $output) ; $_[1]->add_content($output); } $ua = LWP::UserAgent->new; $t = time; for(0..20){ $rs = $ua->get('http://127.0.0.1:60181', 'Accept-Encoding' => 'gzip'); $rs->decode(); } print 'Using HTTP::Response decode() '.(time-$t)."\n"; $z = new Compress::Raw::Zlib::Inflate( -WindowBits => WANT_GZIP, -ConsumeInput => 0 ); $t = time; for(0..20) { $rs = $ua->get('http://127.0.0.1:60181', 'Accept-Encoding' => 'gzip', ':content_cb' => \&callback); } print 'Using callback with block feeding to Compress::Raw::Zlib '.(time-$t);