Skip to content

Instantly share code, notes, and snippets.

@yappo
Created September 4, 2009 07:41
Show Gist options
  • Select an option

  • Save yappo/180787 to your computer and use it in GitHub Desktop.

Select an option

Save yappo/180787 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Benchmark ':all';
use LWP::Simple;
use Cache::Memcached::Fast;
use WWW::Curl::Easy;
use WWW::Curl::Share;
my $mc = Cache::Memcached::Fast->new({ servers => [ 'localhost:12321' ] });
cmpthese(10000, {
memcached => sub {
die unless ($mc->get('/yappo') eq 'yappo');
},
curl => sub {
my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_URL, 'http://localhost:8080/yappo');
open my $content_fh, '>', \my $content;
$curl->setopt( CURLOPT_WRITEDATA, $content_fh);
$curl->perform;
die unless ($content eq 'yappo');
},
http => sub {
die unless (get 'http://localhost:8080/yappo') eq 'yappo';
},
});
__END__
Rate curl http memcached
curl 2033/s -- -17% -44%
http 2457/s 21% -- -32%
memcached 3610/s 78% 47% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment