#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;

my $x = $ARGV[0]; #size of groups
my $z = $ARGV[1]; #num of groups

my $userAgent = LWP::UserAgent->new(agent => 'perl post');

for my $a (1 .. $z)
{
    my $time = time;
    for my $b (1 .. $x)
    {
        my $userStr  = "user-$a-$b";
        my $passStr  = "pass-$a-$b";
        my $message  = "user=$userStr&password=$passStr";
        my $response = $userAgent->request(POST 'http://localhost:8000/add_user',
        Content_Type => 'text/xml',
        Content => $message);

        # Uncomment this for a readout of the last insert successfully
        # handled.
        #print "completed: $userStr $passStr\n" if ($response->is_success);
    }
    my $took = time - $time;
    print "($a) Did [$x] adds in [$took] seconds.\n";
}

