Thursday, September 25, 2008

Testing server performance with multiple connection

Continues from previous post, this method is very useful to test the server performance with multiple request at the same time.

public void testMultiConnection(final String host, final int port,
final List messages, int noOfThread) {
// testing multiple request with different thread
for (int i = 0; i <>
final int threadNumber = i;
Thread connector = new Thread(new Runnable() {
@Override
public void run() {
for (String msg : messages) {
System.out.println("response from Thread["
+ threadNumber + "]:"
+ getResponse(host, port, msg));
}
}
});
connector.start();
}
}

No comments: