summaryrefslogtreecommitdiff
path: root/cpp/demo/Ice/throughput/Client.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2003-03-22 13:27:51 +0000
committerMarc Laukien <marc@zeroc.com>2003-03-22 13:27:51 +0000
commite619b99261850d0c032f035b5d02f293cff72e24 (patch)
tree230577f31681e6377d363625d2c8bdd60faa7d57 /cpp/demo/Ice/throughput/Client.cpp
parentmarshal code optimization (diff)
downloadice-e619b99261850d0c032f035b5d02f293cff72e24.tar.bz2
ice-e619b99261850d0c032f035b5d02f293cff72e24.tar.xz
ice-e619b99261850d0c032f035b5d02f293cff72e24.zip
added throughput demo
Diffstat (limited to 'cpp/demo/Ice/throughput/Client.cpp')
-rw-r--r--cpp/demo/Ice/throughput/Client.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp
new file mode 100644
index 00000000000..004b290464f
--- /dev/null
+++ b/cpp/demo/Ice/throughput/Client.cpp
@@ -0,0 +1,99 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <Throughput.h>
+
+using namespace std;
+
+int
+run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+{
+ Ice::PropertiesPtr properties = communicator->getProperties();
+ const char* proxyProperty = "Throughput.Throughput";
+ std::string proxy = properties->getProperty(proxyProperty);
+ if(proxy.empty())
+ {
+ cerr << argv[0] << ": property `" << proxyProperty << "' not set" << endl;
+ return EXIT_FAILURE;
+ }
+
+ Ice::ObjectPrx base = communicator->stringToProxy(proxy);
+ ThroughputPrx throughput = ThroughputPrx::checkedCast(base);
+ if(!throughput)
+ {
+ cerr << argv[0] << ": invalid proxy" << endl;
+ return EXIT_FAILURE;
+ }
+
+ // Initial ping to setup the connection.
+ throughput->ice_ping();
+
+ IceUtil::Time tsec = IceUtil::Time::now();
+
+ const int repetitions = 100;
+ const int size = 500000;
+
+ cout << "sending and receiving " << repetitions << " sequences of size " << size
+ << " (this may take a while)" << endl;
+ ByteSeq seq(size, 0);
+ for(int i = 0; i < repetitions; ++i)
+ {
+ throughput->echoByteSeq(seq);
+ }
+
+ tsec = IceUtil::Time::now() - tsec;
+
+ double tmsec = tsec * 1000.0L;
+
+ cout << "time for " << repetitions << " sequences: " << tmsec << "ms" << endl;
+ cout << "time per sequence: " << tmsec / repetitions << "ms" << endl;
+
+ return EXIT_SUCCESS;
+}
+
+int
+main(int argc, char* argv[])
+{
+ int status;
+ Ice::CommunicatorPtr communicator;
+
+ try
+ {
+ Ice::PropertiesPtr properties = Ice::createProperties(argc, argv);
+ properties->load("config");
+ communicator = Ice::initializeWithProperties(argc, argv, properties);
+ status = run(argc, argv, communicator);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+
+ if(communicator)
+ {
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ }
+
+ return status;
+}