http://www.perlmonks.org?node_id=329279


in reply to Re: Re: First impressions of WWW::Curl::Lite
in thread First impressions of WWW::Curl::Lite

I'm not a benchmark guru, but I'd also like to see HTTP::MHTTP, HTTP::GHTTP and HTTP::Lite included in the benchmark too.

In my experience, MHTTP is the fastest, GHTTP is pretty close, and Lite is slower, but still faster than LWP. Like LWP, Lite is also pure Perl, and doesn't require a backend c library.


--
ajt

Replies are listed 'Best First'.
Re: Re: Re: Re: First impressions of WWW::Curl::Lite
by sri (Vicar) on Feb 17, 2004 at 00:00 UTC
    Here comes a more complete benchmark, and HTTP::MHTTP won under these conditions!
    #!/usr/bin/perl -w use strict; use Benchmark qw(:all); use lib 'src/WWW-Curl-Lite/lib'; use WWW::Curl::Lite::Request; use WWW::Curl::Lite; use LWP::UserAgent; use LWP::Parallel::UserAgent; use HTTP::Request; use HTTP::MHTTP; my $request = new WWW::Curl::Lite::Request( { url => 'http://127.0.0.1 +' } ); my $curl = new WWW::Curl::Lite; my $ua = new LWP::UserAgent; my $pua = new LWP::Parallel::UserAgent; my $req = new HTTP::Request( GET => 'http://127.0.0.1' ); timethese( 100, { 'curl' => sub { for ( 1 .. 10 ) { $curl->register($request) } $curl->request; }, 'lwp' => sub { for ( 1 .. 10 ) { $ua->request($req) } }, 'lwp-parallel' => sub { $pua->initialize; $pua->nonblock(1); for ( 1 .. 10 ) { $pua->register($req) } $pua->wait; }, 'mhttp' => sub { for ( 1 .. 10 ) { http_init(); http_call( "GET", "http://127.0.0.1" ); http_response(); } } } );
    Benchmark: timing 100 iterations of curl, lwp, lwp-parallel, mhttp... curl: 21 wallclock secs ( 1.00 usr + 0.17 sys = 1.17 CPU) @ 85 +.47/s (n=100) lwp: 36 wallclock secs ( 6.75 usr + 0.53 sys = 7.28 CPU) @ 13 +.74/s (n=100) lwp-parallel: 38 wallclock secs (11.04 usr + 0.61 sys = 11.65 CPU) @ + 8.58/s (n=100) mhttp: 32 wallclock secs ( 0.19 usr + 0.26 sys = 0.45 CPU) @ 22 +2.22/s (n=100)
    A real world benchmark with timeouts and other exceptions would be much more interesting, so don't take this one too serious.
        Yes, LWP::Simple is much faster than LWP::UserAgent.

        #!/usr/bin/perl -w use strict; use Benchmark qw(:all); use lib 'src/WWW-Curl-Lite/lib'; use WWW::Curl::Lite::Request; use WWW::Curl::Lite; use LWP::Simple; use LWP::Parallel::UserAgent; use HTTP::Request; use HTTP::MHTTP; my $request = new WWW::Curl::Lite::Request( { url => 'http://127.0.0.1 +' } ); my $curl = new WWW::Curl::Lite; my $pua = new LWP::Parallel::UserAgent; my $req = new HTTP::Request( GET => 'http://127.0.0.1' ); cmpthese( 100, { 'curl' => sub { for ( 1 .. 10 ) { $curl->register($request) } $curl->request; }, 'lwp' => sub { for ( 1 .. 10 ) { get('http://127.0.0.1') } }, 'lwp-parallel' => sub { $pua->initialize; $pua->nonblock(1); for ( 1 .. 10 ) { $pua->register($req) } $pua->wait; }, 'mhttp' => sub { for ( 1 .. 10 ) { http_init(); http_call( "GET", "http://127.0.0.1" ); http_response(); } } } );
        Rate lwp-parallel lwp curl mhtt +p lwp-parallel 9.07/s -- -78% -89% -96 +% lwp 41.3/s 355% -- -50% -81 +% curl 83.3/s 818% 102% -- -62 +% mhttp 217/s 2296% 426% 161% - +-