WWW::Curl vs LWP

機能に差があるので、公平なテストじゃないけどWWW::Curl速い

結果
Benchmark: timing 500 iterations of curl, lwp...
      curl:  1 wallclock secs ( 0.31 usr +  0.30 sys =  0.61 CPU) @ 819.67/s (n=500)
       lwp:  4 wallclock secs ( 3.13 usr +  0.37 sys =  3.50 CPU) @ 142.86/s (n=500)
スクリプト
use Benchmark;
use LWP::UserAgent;
use WWW::Curl::Easy;

my $count = 500;

timethese( $count , {
    'curl' => sub {
        open(my $content_fh, '>', \my $content);
        open(my $header_fh, '>', \my $header);
        my $curl = WWW::Curl::Easy->new();
        $curl->setopt( CURLOPT_WRITEDATA, $content_fh);
        $curl->setopt( CURLOPT_WRITEHEADER, $header_fh);
        $curl->setopt( CURLOPT_URL, 'http://localhost/' );
        $curl->perform();
    },
    'lwp' => sub {
        my $ua = LWP::UserAgent->new;
        my $res = $ua->get('http://localhost/');
    }
});
created by blog.nomadscafe.jp

コメント

posted by http://blog.nomadscafe.jp/ | 2008-10-10 22:04:52

同じサーバのApacheBenchの結果

Concurrency Level:      1
Time taken for tests:   7.657236 seconds
Complete requests:      5000
Failed requests:        0
Write errors:           0
Total transferred:      3355000 bytes
HTML transferred:       2190000 bytes
Requests per second:    652.98 [#/sec] (mean)
Time per request:       1.531 [ms] (mean)
Time per request:       1.531 [ms] (mean, across all concurrent requests)
Transfer rate:          427.83 [Kbytes/sec] received

コメントを投稿

コメントを投稿するにはログインが必要です