summaryrefslogtreecommitdiff
path: root/cpp/src/tests/latencytest.cpp
diff options
context:
space:
mode:
authorCarl C. Trieloff <cctrieloff@apache.org>2009-01-06 20:22:34 +0000
committerCarl C. Trieloff <cctrieloff@apache.org>2009-01-06 20:22:34 +0000
commitcd161749af72635be9721dbbd72cdffa76180e45 (patch)
tree4cc1d19e8308bcc5f5c13fa4d04572e275c1f329 /cpp/src/tests/latencytest.cpp
parent1927fcf06c4db92f87b49bc90c7e31c1e5ead6d0 (diff)
downloadqpid-python-cd161749af72635be9721dbbd72cdffa76180e45.tar.gz
Add option to use single connection for all producers, and consumers to test high queue count configurations without using many physical connections.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@732096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/latencytest.cpp')
-rw-r--r--cpp/src/tests/latencytest.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/cpp/src/tests/latencytest.cpp b/cpp/src/tests/latencytest.cpp
index 6895964133..2414944cef 100644
--- a/cpp/src/tests/latencytest.cpp
+++ b/cpp/src/tests/latencytest.cpp
@@ -55,16 +55,19 @@ struct Args : public qpid::TestOptions {
bool csv;
bool durable;
string base;
+ bool singleConnect;
Args() : size(256), count(1000), rate(0), reportFrequency(1000),
timeLimit(0), queues(1),
prefetch(100), ack(0),
- durable(false), base("latency-test")
+ durable(false), base("latency-test"), singleConnect(false)
+
{
addOptions()
("size", optValue(size, "N"), "message size")
("queues", optValue(queues, "N"), "number of queues")
+ ("single-connection", optValue(singleConnect, "yes|no"), "Use one connection for multiple sessions.")
("count", optValue(count, "N"), "number of messages to send")
("rate", optValue(rate, "N"), "target message rate (causes count to be ignored)")
("sync", optValue(sync), "send messages synchronously")
@@ -85,6 +88,7 @@ const std::string chars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
Args opts;
double c_min, c_avg, c_max;
+Connection globalConnection;
uint64_t current_time()
{
@@ -109,14 +113,15 @@ struct Stats
class Client : public Runnable
{
protected:
- Connection connection;
+ Connection* connection;
+ Connection localConnection;
AsyncSession session;
Thread thread;
string queue;
public:
Client(const string& q);
- virtual ~Client() {}
+ virtual ~Client();
void start();
void join();
@@ -171,8 +176,14 @@ public:
Client::Client(const string& q) : queue(q)
{
- opts.open(connection);
- session = connection.newSession();
+ if (opts.singleConnect){
+ connection = &globalConnection;
+ if (!globalConnection.isOpen()) opts.open(globalConnection);
+ }else{
+ connection = &localConnection;
+ opts.open(localConnection);
+ }
+ session = connection->newSession();
}
void Client::start()
@@ -189,8 +200,16 @@ void Client::run()
{
try{
test();
+ } catch(const std::exception& e) {
+ std::cout << "Error in receiver: " << e.what() << std::endl;
+ }
+}
+
+Client::~Client()
+{
+ try{
session.close();
- connection.close();
+ connection->close();
} catch(const std::exception& e) {
std::cout << "Error in receiver: " << e.what() << std::endl;
}