summaryrefslogtreecommitdiff
path: root/cpp/demo/Ice/throughput/Client.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2003-07-30 10:51:25 +0000
committerMarc Laukien <marc@zeroc.com>2003-07-30 10:51:25 +0000
commit7d03c49bd820fa2a88bd2c20104463ff8c109e5c (patch)
tree283171e9d5582e5eb6bf1d7a980bff7c84008b18 /cpp/demo/Ice/throughput/Client.cpp
parentAdded DatagramLimitException. (diff)
downloadice-7d03c49bd820fa2a88bd2c20104463ff8c109e5c.tar.bz2
ice-7d03c49bd820fa2a88bd2c20104463ff8c109e5c.tar.xz
ice-7d03c49bd820fa2a88bd2c20104463ff8c109e5c.zip
more options
Diffstat (limited to 'cpp/demo/Ice/throughput/Client.cpp')
-rw-r--r--cpp/demo/Ice/throughput/Client.cpp136
1 files changed, 120 insertions, 16 deletions
diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp
index 674314eb1d3..c807e409300 100644
--- a/cpp/demo/Ice/throughput/Client.cpp
+++ b/cpp/demo/Ice/throughput/Client.cpp
@@ -17,6 +17,19 @@
using namespace std;
+void
+menu()
+{
+ cout <<
+ "usage:\n"
+ "s: send byte sequence\n"
+ "o: send byte sequence as oneway\n"
+ "r: receive byte sequence\n"
+ "e: echo (send and receive) byte sequence\n"
+ "x: exit\n"
+ "?: help\n";
+}
+
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
@@ -36,28 +49,119 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
cerr << argv[0] << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
+ ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway());
- // Initial ping to setup the connection.
- throughput->ice_ping();
-
- IceUtil::Time tsec = IceUtil::Time::now();
+ ByteSeq seq(seqSize, 0);
- const int repetitions = 100;
+ menu();
- cout << "sending and receiving " << repetitions << " sequences of size " << seqSize
- << " (this may take a while)" << endl;
- ByteSeq seq(seqSize, 0);
- for(int i = 0; i < repetitions; ++i)
+ char c;
+ do
{
- throughput->echoByteSeq(seq);
- }
+ try
+ {
+ cout << "==> ";
+ cin >> c;
+
+ throughput->ice_ping(); // Initial ping to setup the connection.
+
+ IceUtil::Time tsec = IceUtil::Time::now();
+ const int repetitions = 100;
- tsec = IceUtil::Time::now() - tsec;
+ if(c == 's' || c == 'o' || c == 'r' || c == 'e')
+ {
+ switch(c)
+ {
+ case 's':
+ case 'o':
+ {
+ cout << "sending";
+ break;
+ }
- double tmsec = tsec * 1000.0L;
-
- cout << "time for " << repetitions << " sequences: " << tmsec << "ms" << endl;
- cout << "time per sequence: " << tmsec / repetitions << "ms" << endl;
+ case 'r':
+ {
+ cout << "receiving";
+ break;
+ }
+
+ case 'e':
+ {
+ cout << "sending and receiving";
+ break;
+ }
+ }
+
+ cout << ' ' << repetitions << " sequences of size " << seqSize;
+
+ if(c == 'o')
+ {
+ cout << " as oneway";
+ }
+
+ cout << "..." << endl;
+
+ for(int i = 0; i < repetitions; ++i)
+ {
+ switch(c)
+ {
+ case 's':
+ {
+ throughput->sendByteSeq(seq);
+ break;
+ }
+
+ case 'o':
+ {
+ throughputOneway->sendByteSeq(seq);
+ break;
+ }
+
+ case 'r':
+ {
+ throughput->recvByteSeq();
+ break;
+ }
+
+ case 'e':
+ {
+ throughput->echoByteSeq(seq);
+ break;
+ }
+ }
+ }
+
+ 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;
+ double mbit = repetitions * seqSize * 8.0 / tsec / 1000000.0;
+ if(c == 'e')
+ {
+ mbit *= 2;
+ }
+ cout << "throughput: " << mbit << " MBit/s" << endl;
+ }
+ else if(c == 'x')
+ {
+ // Nothing to do
+ }
+ else if(c == '?')
+ {
+ menu();
+ }
+ else
+ {
+ cout << "unknown command `" << c << "'" << endl;
+ menu();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ }
+ }
+ while(cin.good() && c != 'x');
return EXIT_SUCCESS;
}