qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cctriel...@apache.org
Subject svn commit: r732096 - /qpid/trunk/qpid/cpp/src/tests/latencytest.cpp
Date Tue, 06 Jan 2009 20:22:34 GMT
Author: cctrieloff
Date: Tue Jan  6 12:22:34 2009
New Revision: 732096

URL: http://svn.apache.org/viewvc?rev=732096&view=rev
Log:
Add option to use single connection for all producers, and consumers to test high queue count
configurations without using many physical connections.

Modified:
    qpid/trunk/qpid/cpp/src/tests/latencytest.cpp

Modified: qpid/trunk/qpid/cpp/src/tests/latencytest.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp?rev=732096&r1=732095&r2=732096&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/latencytest.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/latencytest.cpp Tue Jan  6 12:22:34 2009
@@ -55,16 +55,19 @@
     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 @@
 
 Args opts;
 double c_min, c_avg, c_max;
+Connection globalConnection;
 
 uint64_t current_time()
 {
@@ -109,14 +113,15 @@
 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 @@
 
 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 @@
 {
     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;
     }



Mime
View raw message