diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Ice/throughput/Client.cpp | 200 | ||||
-rw-r--r-- | cpp/demo/Ice/throughput/Throughput.ice | 20 | ||||
-rw-r--r-- | cpp/demo/Ice/throughput/ThroughputI.h | 49 |
3 files changed, 237 insertions, 32 deletions
diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp index 11bae701e8c..9a029d9a30b 100644 --- a/cpp/demo/Ice/throughput/Client.cpp +++ b/cpp/demo/Ice/throughput/Client.cpp @@ -18,10 +18,15 @@ menu() { cout << "usage:\n" - "t: send byte sequence as twoway\n" - "o: send byte sequence as oneway\n" - "r: receive byte sequence\n" - "e: echo (send and receive) byte sequence\n" + "toggle type of data to send\n" + " 1: byte sequence (default)\n" + " 2: string { \"hello\" } sequence\n" + " 3: struct { \"hello\", \"3.14\" } sequence\n" + "select test to run\n" + " t: send sequence as twoway\n" + " o: send sequence as oneway\n" + " r: receive sequence\n" + " e: echo (send and receive) sequence\n" "s: shutdown server\n" "x: exit\n" "?: help\n"; @@ -48,12 +53,31 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway()); - ByteSeq seq(seqSize, 0); + int byteSeqSize = 500000; + int stringSeqSize = 100000; + int structSeqSize = 50000; + + ByteSeq byteSeq(byteSeqSize, 0); + + StringSeq stringSeq(stringSeqSize, "hello"); + + StringDoubleSeq structSeq(structSeqSize); + for(int i = 0; i < structSeqSize; ++i) + { + structSeq[i].s = "hello"; + structSeq[i].d = 3.14; + } menu(); throughput->ice_ping(); // Initial ping to setup the connection. + // + // By default use byte sequence. + // + char currentType = '1'; + int seqSize = byteSeqSize; + char c; do { @@ -65,7 +89,34 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) IceUtil::Time tm = IceUtil::Time::now(); const int repetitions = 1000; - if(c == 't' || c == 'o' || c == 'r' || c == 'e') + if(c == '1' || c == '2' || c == '3') + { + currentType = c; + switch(c) + { + case '1': + { + cout << "using byte sequences" << endl; + seqSize = byteSeqSize; + break; + } + + case '2': + { + cout << "using string sequences" << endl; + seqSize = stringSeqSize; + break; + } + + case '3': + { + cout << "using struct sequences" << endl; + seqSize = structSeqSize; + break; + } + } + } + else if(c == 't' || c == 'o' || c == 'r' || c == 'e') { switch(c) { @@ -89,7 +140,29 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } } - cout << ' ' << repetitions << " sequences of size " << seqSize; + cout << ' ' << repetitions; + switch(currentType) + { + case '1': + { + cout << " byte"; + break; + } + + case '2': + { + cout << " string"; + break; + } + + case '3': + { + cout << " struct"; + break; + } + } + cout << " sequences of size " << seqSize; + if(c == 'o') { @@ -100,30 +173,97 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(int i = 0; i < repetitions; ++i) { - switch(c) + switch(currentType) { - case 't': + case '1': { - throughput->sendByteSeq(seq); - break; - } + switch(c) + { + case 't': + { + throughput->sendByteSeq(byteSeq); + break; + } - case 'o': - { - throughputOneway->sendByteSeq(seq); - break; - } + case 'o': + { + throughputOneway->sendByteSeq(byteSeq); + break; + } - case 'r': - { - throughput->recvByteSeq(); + case 'r': + { + throughput->recvByteSeq(); + break; + } + + case 'e': + { + throughput->echoByteSeq(byteSeq); + break; + } + } break; } + + case '2': + { + switch(c) + { + case 't': + { + throughput->sendStringSeq(stringSeq); + break; + } + + case 'o': + { + throughputOneway->sendStringSeq(stringSeq); + break; + } - case 'e': + case 'r': + { + throughput->recvStringSeq(); + break; + } + + case 'e': + { + throughput->echoStringSeq(stringSeq); + break; + } + } + } + + case '3': { - throughput->echoByteSeq(seq); - break; + switch(c) + { + case 't': + { + throughput->sendStructSeq(structSeq); + break; + } + + case 'o': + { + throughputOneway->sendStructSeq(structSeq); + break; + } + + case 'r': + { + throughput->recvStructSeq(); + break; + } + + case 'e': + { + throughput->echoStructSeq(structSeq); + break; + } + } } } } @@ -131,12 +271,18 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) tm = IceUtil::Time::now() - tm; cout << "time for " << repetitions << " sequences: " << tm * 1000 << "ms" << endl; cout << "time per sequence: " << tm * 1000 / repetitions << "ms" << endl; - double mbit = repetitions * seqSize * 8.0 / tm.toMicroSeconds(); - if(c == 'e') + if(currentType == '1') { - mbit *= 2; + // + // TODO: Calculate rate for strings and structs. + // + double mbit = repetitions * seqSize * 8.0 / tm.toMicroSeconds(); + if(c == 'e') + { + mbit *= 2; + } + cout << "throughput: " << mbit << " MBit/s" << endl; } - cout << "throughput: " << mbit << " MBit/s" << endl; } else if(c == 's') { diff --git a/cpp/demo/Ice/throughput/Throughput.ice b/cpp/demo/Ice/throughput/Throughput.ice index d0a541a1145..978e43c7194 100644 --- a/cpp/demo/Ice/throughput/Throughput.ice +++ b/cpp/demo/Ice/throughput/Throughput.ice @@ -13,15 +13,31 @@ module Demo { -const int seqSize = 500000; - sequence<byte> ByteSeq; +sequence<string> StringSeq; + +struct StringDouble +{ + string s; + double d; +}; +sequence<StringDouble> StringDoubleSeq; + interface Throughput { void sendByteSeq(ByteSeq seq); ByteSeq recvByteSeq(); ByteSeq echoByteSeq(ByteSeq seq); + + void sendStringSeq(StringSeq seq); + StringSeq recvStringSeq(); + StringSeq echoStringSeq(StringSeq seq); + + void sendStructSeq(StringDoubleSeq seq); + StringDoubleSeq recvStructSeq(); + StringDoubleSeq echoStructSeq(StringDoubleSeq seq); + idempotent void shutdown(); }; diff --git a/cpp/demo/Ice/throughput/ThroughputI.h b/cpp/demo/Ice/throughput/ThroughputI.h index 7817500af0b..7454c9d0a94 100644 --- a/cpp/demo/Ice/throughput/ThroughputI.h +++ b/cpp/demo/Ice/throughput/ThroughputI.h @@ -18,8 +18,15 @@ class ThroughputI : public Demo::Throughput public: ThroughputI() : - _seq(Demo::seqSize, 0) + _byteSeq(500000, 0), + _stringSeq(100000, "hello"), + _structSeq(50000) { + for(int i = 0; i < 50000; ++i) + { + _structSeq[i].s = "hello"; + _structSeq[i].d = 3.14; + } } virtual void @@ -30,7 +37,7 @@ public: virtual Demo::ByteSeq recvByteSeq(const Ice::Current&) { - return _seq; + return _byteSeq; } virtual Demo::ByteSeq @@ -40,6 +47,40 @@ public: } virtual void + sendStringSeq(const Demo::StringSeq&, const Ice::Current&) + { + } + + virtual Demo::StringSeq + recvStringSeq(const Ice::Current&) + { + return _stringSeq; + } + + virtual Demo::StringSeq + echoStringSeq(const Demo::StringSeq& seq, const Ice::Current&) + { + return seq; + } + + virtual void + sendStructSeq(const Demo::StringDoubleSeq&, const Ice::Current&) + { + } + + virtual Demo::StringDoubleSeq + recvStructSeq(const Ice::Current&) + { + return _structSeq; + } + + virtual Demo::StringDoubleSeq + echoStructSeq(const Demo::StringDoubleSeq& seq, const Ice::Current&) + { + return seq; + } + + virtual void shutdown(const Ice::Current& c) { c.adapter->getCommunicator()->shutdown(); @@ -47,7 +88,9 @@ public: private: - Demo::ByteSeq _seq; + Demo::ByteSeq _byteSeq; + Demo::StringSeq _stringSeq; + Demo::StringDoubleSeq _structSeq; }; #endif |