#!/usr/bin/perl

@threadnums = (1,2,4,8,16,32);
@loopnums = (1,100,1000,10000,100000,500000);
$base =10000;
foreach $threadnum (@threadnums)
{
    foreach $loopnum (@loopnums)
    {
        print("./server $base $threadnum $loopnum > temp.threads &\n");
	system("./server $base $threadnum $loopnum > temp.threads &");
	sleep(10);
	for($i=0;$i<$threadnum *2;$i++)
	{
	    print("./client 127.1 $base &\n");
	    system("./client 127.1 $base &");
	}
	while(-s "temp.threads" == 0)
	{
	    sleep(1);
	}
	system("echo \"$threadnum $loopnum \" >> thread.results");
	system("cat temp.threads | tee >> thread.results");
	system("echo \"\n\" >> thread.results");
	unlink("temp.threads");
	sleep(1);
	$base++;
    }
}

