}
int perform(final int workers, final int loops, final int port, final Integer size) throws Exception {
final AtomicInteger total = new AtomicInteger();
running = 0;
errors.clear();
for (int i = 0; i < workers; i++) {
Thread t = new Thread() {
public void run() {
running++;
try {
HttpClient httpClient = new HttpClient();
for (int j = 0; j < loops; j++) {
long start = System.currentTimeMillis();
IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + port + "/"));
long elapsed = (System.currentTimeMillis() - start);
total.addAndGet((int) elapsed);
Assert.assertEquals(200, response.getStatus());
if (size != null) {
Assert.assertEquals(size.intValue(), response.getBody().size());
}
//System.out.println(elapsed + " millis");
}
} catch (Exception e) {
errors.add(e.toString());
}
running--;
}
};
t.start();
}
do {
QAUtil.sleep(100);
} while (running > 0);
return total.get();
}