From: erickson Date: Fri, 18 May 2007 19:55:59 +0000 (+0000) Subject: added some inline comments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c9a1438e2cb2cc883cd883c6e9a96b7fc16d6245;p=working%2FOpenSRF.git added some inline comments git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@903 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/java/org/opensrf/test/MathBench.java b/src/java/org/opensrf/test/MathBench.java index 3086bf3..b6e67f9 100644 --- a/src/java/org/opensrf/test/MathBench.java +++ b/src/java/org/opensrf/test/MathBench.java @@ -12,15 +12,22 @@ public class MathBench { public static void main(String args[]) throws Exception { PrintStream out = System.out; + if(args.length < 2) { out.println("usage: java org.opensrf.test.MathBench "); return; } + /** connect to the opensrf network */ Sys.bootstrapClient(args[0], "/config/opensrf"); + + /** how many iterations */ int count = Integer.parseInt(args[1]); + /** create the client session */ ClientSession session = new ClientSession("opensrf.math"); + + /** params are 1,2 */ List params = new ArrayList(); params.add(new Integer(1)); params.add(new Integer(2)); @@ -33,8 +40,14 @@ public class MathBench { for(int i = 0; i < count; i++) { start = new Date().getTime(); + + /** create (and send) the request */ request = session.request("add", params); - result = request.recv(5000); + + /** wait up to 3 seconds for a response */ + result = request.recv(3000); + + /** collect the round-trip time */ total += new Date().getTime() - start; if(result.getStatusCode() == Status.OK) { @@ -45,13 +58,19 @@ public class MathBench { out.println("status code = " + result.getStatusCode()); } + /** remove this request from the session's request set */ request.cleanup(); - if((i+1) % 100 == 0) /* print 100 per line */ - out.println(""); + if((i+1) % 100 == 0) /** print 100 responses per line */ + out.println(" [" + (i+1) + "]"); } out.println("\nAverage request time is " + (total/count) + " ms"); + + /** remove this session from the global session cache */ + session.cleanup(); + + /** disconnect from the opensrf network */ Sys.shutdown(); } }