summaryrefslogtreecommitdiff
path: root/java/demo/Ice/throughput/Client.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2003-04-25 19:59:14 +0000
committerMark Spruiell <mes@zeroc.com>2003-04-25 19:59:14 +0000
commit95a9deb459eada060fbeb1186c53ba93d94580dc (patch)
tree59e6312d24668ae41333a2541fd48ff3796f4137 /java/demo/Ice/throughput/Client.java
parentminor fix for const problem (diff)
downloadice-95a9deb459eada060fbeb1186c53ba93d94580dc.tar.bz2
ice-95a9deb459eada060fbeb1186c53ba93d94580dc.tar.xz
ice-95a9deb459eada060fbeb1186c53ba93d94580dc.zip
porting throughput demo
Diffstat (limited to 'java/demo/Ice/throughput/Client.java')
-rw-r--r--java/demo/Ice/throughput/Client.java94
1 files changed, 94 insertions, 0 deletions
diff --git a/java/demo/Ice/throughput/Client.java b/java/demo/Ice/throughput/Client.java
new file mode 100644
index 00000000000..9a6fdc7a192
--- /dev/null
+++ b/java/demo/Ice/throughput/Client.java
@@ -0,0 +1,94 @@
+// **********************************************************************
+//
+// Copyright (c) 2003
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+public class Client
+{
+ private static int
+ run(String[] args, Ice.Communicator communicator)
+ {
+ Ice.Properties properties = communicator.getProperties();
+ final String refProperty = "Throughput.Throughput";
+ String ref = properties.getProperty(refProperty);
+ if(ref.length() == 0)
+ {
+ System.err.println("property `" + refProperty + "' not set");
+ return 1;
+ }
+
+ Ice.ObjectPrx base = communicator.stringToProxy(ref);
+ ThroughputPrx throughput = ThroughputPrxHelper.checkedCast(base);
+ if(throughput == null)
+ {
+ System.err.println("invalid proxy");
+ return 1;
+ }
+
+ // Initial ping to setup the connection.
+ throughput.ice_ping();
+
+ long tmsec = System.currentTimeMillis();
+
+ final int repetitions = 100;
+
+ System.out.println("sending and receiving " + repetitions + " sequences of size " + seqSize.value +
+ " (this may take a while)");
+ byte[] seq = new byte[seqSize.value];
+ for(int i = 0; i < repetitions; i++)
+ {
+ throughput.echoByteSeq(seq);
+ }
+
+ double dmsec = System.currentTimeMillis() - tmsec;
+
+ System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms");
+ System.out.println("time per sequence: " + (dmsec / repetitions) + "ms");
+
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ int status = 0;
+ Ice.Communicator communicator = null;
+
+ try
+ {
+ Ice.Properties properties = Ice.Util.createProperties(args);
+ properties.load("config");
+ communicator = Ice.Util.initializeWithProperties(args, properties);
+ status = run(args, communicator);
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ status = 1;
+ }
+
+ if(communicator != null)
+ {
+ try
+ {
+ communicator.destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ status = 1;
+ }
+ }
+
+ System.exit(status);
+ }
+}