smetj has asked for the wisdom of the Perl Monks concerning the following question:
Query using Curl:#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use JSON; my $client = new LWP::UserAgent; my $json = new JSON; my %request=('commandlet'=>'memory','output'=>'json'); my $json_request = $json->encode(\%request); my $web_request = $client->post('http://localhost:12345/query',{ usern +ame => 'default', password => 'changeme', json => $json_request }); print $web_request->content;
If I write a bash script which iterates 100 times over both scripts I get following results:#!/usr/bin/perl use strict; use warnings; use JSON; my $json = new JSON; my %request=('commandlet'=>'memory','output'=>'json'); my $json_data=$json->encode(\%request); my $command=sprintf"/usr/bin/curl -d username='%s' -d password='%s' -- +data-urlencode json='%s' http://localhost:12345/query 2>/dev/null|"," +default","changeme",$json_data; open FH,$command; while (<FH>){ print $_; } close FH;
I'm running Ubuntu 9.1 and LWP::UserAgent has version "5.829"Using curl: real 0m4.006s user 0m3.060s sys 0m0.740s Using LWP real 0m12.978s user 0m11.405s sys 0m1.184s
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why is LWP::UserAgent so slow?
by zwon (Abbot) on Feb 10, 2010 at 19:38 UTC | |
by mje (Curate) on Feb 11, 2010 at 09:04 UTC | |
by smetj (Initiate) on Feb 18, 2010 at 19:37 UTC | |
|
Re: Why is LWP::UserAgent so slow?
by Anonymous Monk on Feb 10, 2010 at 10:35 UTC |