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

Here is a quick Benchmark:
#!/usr/bin/perl -w use strict; use Benchmark qw(:all); use WWW::Curl::Lite::Request; use WWW::Curl::Lite; use LWP::UserAgent; use LWP::Parallel::UserAgent; use HTTP::Request; 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 $httpreq = 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->get('http://127.0.0.1') } }, 'lwp-parallel' => sub { $pua->initialize; $pua->nonblock(1); for ( 1 .. 10 ) { $pua->register($httpreq) } $pua->wait; } } );
sri@odyssey:~$ perl benchmark2.pl Benchmark: timing 100 iterations of curl, lwp, lwp-parallel... curl: 25 wallclock secs ( 1.07 usr + 0.18 sys = 1.25 CPU) @ 80 +.00/s (n=100) lwp: 30 wallclock secs ( 7.12 usr + 0.51 sys = 7.63 CPU) @ 13 +.11/s (n=100) lwp-parallel: 34 wallclock secs (11.07 usr + 0.56 sys = 11.63 CPU) @ + 8.60/s (n=100)
Most suprising is how bad LWP::Parallel performed.

Yes, it wasn't 30 times faster in this benchmark, the original one was performed on a small crawler cluster with 10000 real world url's, maybe i can reformat these results and post them too.

Replies are listed 'Best First'.
Re: Re: Re: First impressions of WWW::Curl::Lite
by ajt (Prior) on Feb 16, 2004 at 12:01 UTC

    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
      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.
Re^3: First impressions of WWW::Curl::Lite
by Aristotle (Chancellor) on Feb 16, 2004 at 21:55 UTC
    That seems to unfairly penalize LWP by using a shortcut method that constructs a request on every iteration while you pre-construct it for the other methods.

    Makeshifts last the longest.

      It doesn't really matter...
      #!/usr/bin/perl -w use strict; use Benchmark qw(:all); use WWW::Curl::Lite::Request; use WWW::Curl::Lite; use LWP::UserAgent; use LWP::Parallel::UserAgent; use HTTP::Request; 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 $httpreq = 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($httpreq) } }, 'lwp-parallel' => sub { $pua->initialize; $pua->nonblock(1); for ( 1 .. 10 ) { $pua->register($httpreq) } $pua->wait; } } );
      Benchmark: timing 100 iterations of curl, lwp, lwp-parallel... curl: 26 wallclock secs ( 1.04 usr + 0.15 sys = 1.19 CPU) @ 84 +.03/s (n=100) lwp: 30 wallclock secs ( 6.86 usr + 0.51 sys = 7.37 CPU) @ 13 +.57/s (n=100) lwp-parallel: 34 wallclock secs (11.07 usr + 0.53 sys = 11.60 CPU) @ + 8.62/s (n=100)