pronane
asked on
http client/stress tool
I am trying to create a basic test tool, that hopefully will develop into a bigger project, basically I want to create a simple threaded httpclient that will send multiple requests to a server, record the avg response time, response time etc. I want to know what would be the best way to modify this using threads and is their anything I have to look out for. How can I record the response times etc, as I want to create a graph from the results?? Has anyone tried this before? ANy good links etc?? I have read a lot, I know im capable of doing it, I just want to be put on the right track.
Some sample code would be great.
import java.net.*;
import java.io.*;
import java.util.*;
public class WebTest
{
public static void main (String[] args)
{
// initialize random seed
Random randomGen = new Random(new Date().getTime());
while(true)
{
try
{
// sleep for a random interval
Thread.currentThread().sle ep(randomG en.nextInt (args.leng th>1?(new Integer(args[1]).intValue( )):10000)) ;
if(args.length>0)
{
// print the user supplied URL to the console window
System.out.println(args[0] );
// open URL connection
URLConnection urlConn = new URL(args[0]).openConnectio n();
urlConn.setUseCaches(false );
// read and print the content to the console window
InputStream in = urlConn.getInputStream();
byte buf[] = new byte[4096];
int nSize = in.read(buf);
while(nSize>=0)
{
System.out.print(new String(buf,0,nSize));
nSize = in.read(buf);
}
System.out.print("\r\n");
}
else return;
}
catch(Exception e)
{
// print error message
System.out.println("Except ion: "+e.getMessage());
}
}
}
}
Thanks,
Paul
Some sample code would be great.
import java.net.*;
import java.io.*;
import java.util.*;
public class WebTest
{
public static void main (String[] args)
{
// initialize random seed
Random randomGen = new Random(new Date().getTime());
while(true)
{
try
{
// sleep for a random interval
Thread.currentThread().sle
if(args.length>0)
{
// print the user supplied URL to the console window
System.out.println(args[0]
// open URL connection
URLConnection urlConn = new URL(args[0]).openConnectio
urlConn.setUseCaches(false
// read and print the content to the console window
InputStream in = urlConn.getInputStream();
byte buf[] = new byte[4096];
int nSize = in.read(buf);
while(nSize>=0)
{
System.out.print(new String(buf,0,nSize));
nSize = in.read(buf);
}
System.out.print("\r\n");
}
else return;
}
catch(Exception e)
{
// print error message
System.out.println("Except
}
}
}
}
Thanks,
Paul
ASKER
Any ideas on any of the other parts of the question, thanks for that link, didnt know that before ;) The one thing I want to do correctly is receving stats and graphing them, Im not really sure how to go about that at all.
it basically does what you want to do...
ASKER
ya i know that ive tested it and used it. its the basis of what i want to do.
ASKER
No one got any other ideas? Thanks for the above responses but this is stuff I knew already, can I claim my point back? Sorry its just I hoped to get a better response. Thanks again.
Jmeter is open source... if you're gonna copy it, you might as well do it from the source ;-)
To get this question deleted or moved to PAQ for free (which is better, as people can see the responses), post a message here:
https://www.experts-exchange.com/Community_Support/CleanUp/
Explaining the url for this question, what you want doing, and why...
To get this question deleted or moved to PAQ for free (which is better, as people can see the responses), post a message here:
https://www.experts-exchange.com/Community_Support/CleanUp/
Explaining the url for this question, what you want doing, and why...
A request for deletion has been made. If no response or you feel this is in error, comment. If no objection, I will delete in three days.
Computer101
E-E Admin
Computer101
E-E Admin
Personally i think the advice that's been given has been neither useless nor effortless.
Neither do I :-(
He even said "thanks for that link, didnt know that before" to CEHJ's comment...
He even said "thanks for that link, didnt know that before" to CEHJ's comment...
Got it, recommendations for closure?
Computer101
E-E Admin
Computer101
E-E Admin
Points split between me and Tim please
ASKER
I knew this already, thats why, however if one/both of you answer me this question then I will give the points. Is that fair enough ??? ;)
ASKER
the recommendations is I didnt get a sufficient answer or an answer that helped me with what I am trying to do.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See http://archive.devx.com/upload/free/features/javapro/2000/10oct00/tm0010/tm0010.asp
for instance