crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

xr-http-test (706B)


      1 #!/usr/bin/perl
      2 
      3 use strict;
      4 use LWP::UserAgent;
      5 use Time::HiRes qw(sleep gettimeofday tv_interval);
      6 
      7 $|++;
      8 
      9 die <<"ENDUSAGE" if ($#ARGV != 2);
     10 
     11 Usage: $0 URL THREADS DURATION
     12 Will start THREADS to get URL. The entire test will run for DURATION
     13 seconds.
     14 
     15 ENDUSAGE
     16 
     17 my ($url, $threads, $duration) = @ARGV;
     18 for my $i (1..$threads) {
     19     next if (fork());
     20 
     21     my $t_start = [gettimeofday()];
     22     my $runs = 0;
     23     while (tv_interval($t_start) < $duration) {
     24         $runs++;
     25         my $t_run = [gettimeofday()];
     26 	my $ua = LWP::UserAgent->new();
     27 	$ua->timeout(5);
     28 	my $resp = $ua->get($url);
     29         print(tv_interval($t_run), "\n")
     30 	  if ($resp->is_success());
     31     }
     32     exit(0);
     33 }
     34 
     35 while(wait() != -1) {
     36 }