in reply to Using network calls to load test
To use LWP::UserAgent to get a webpage (or part therof), complete with parsed header you would do:
use Data::Dumper; use LWP::UserAgent; my $gif = 'http://some.domain.com/path/to/some.gif'; my $ua = new LWP::UserAgent; my $req = new HTTP::Request GET => $gif; my $res = $ua->request($req); print Dumper $res;
You will see the data hash you get back ie $res->{_content} , $res->{_rc} is the return code ie 200 OK or 503 overloaded, etc. I have included Data::Dumper so you can see the data structure, not because you need it.
Now if you want to time this you would use Time::HiRes
use Time::HiRes 'time'; my $begin = time(); # do stuff, lets waste some time $cnt++ for 1..1000000; my $end = time(); my $time = ($end - $begin) * 1000; print "Took $time milliseconds\n" ;
So if you want to time stuff just add parts 1 and 2. Now if you want to do load testing either use this in combination with LWP::Parallel::UserAgent or just fork off X number of kids running this code yourself.
my $kids = 100; for ( 1.. $kids ) { my $pid = fork(); next if $pid; # add code for child to process here }
This will fork you 100 kids so just stick the code above in, write the data from each kid to a logfile and Bob's your uncle.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|