summaryrefslogtreecommitdiff
path: root/cpp/src/tests/consume.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-08-26 18:35:00 +0000
committerAlan Conway <aconway@apache.org>2008-08-26 18:35:00 +0000
commit01f8085bf6a14b5c29fae40ea5e9eac54f152dd7 (patch)
tree72cf82df3402baa99a8d38fbe483fc4d83fd5e69 /cpp/src/tests/consume.cpp
parent2486ee3848b613606a7dcdec8a6a399eafcc64b9 (diff)
downloadqpid-python-01f8085bf6a14b5c29fae40ea5e9eac54f152dd7.tar.gz
Test improvements.
- print rates for publish, consume - consistent use of -s for spreadsheet-friendly output. - start_cluster_hosts to start multi-host cluster via ssh. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@689166 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/consume.cpp')
-rw-r--r--cpp/src/tests/consume.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/cpp/src/tests/consume.cpp b/cpp/src/tests/consume.cpp
index c20a738755..29c61ada1b 100644
--- a/cpp/src/tests/consume.cpp
+++ b/cpp/src/tests/consume.cpp
@@ -34,23 +34,26 @@
using namespace qpid;
using namespace qpid::client;
using namespace qpid::sys;
-using std::string;
+using namespace std;
-typedef std::vector<std::string> StringSet;
+typedef vector<string> StringSet;
struct Args : public qpid::TestOptions {
uint count;
uint ack;
string queue;
bool declare;
+ bool summary;
- Args() : count(0), ack(1)
+ Args() : count(1000), ack(0), queue("publish-consume"),
+ declare(false), summary(false)
{
addOptions()
("count", optValue(count, "N"), "number of messages to publish")
("ack-frequency", optValue(ack, "N"), "ack every N messages (0 means use no-ack mode)")
("queue", optValue(queue, "<queue name>"), "queue to consume from")
- ("declare", optValue(declare), "declare the queue");
+ ("declare", optValue(declare), "declare the queue")
+ ("s,summary", optValue(summary), "Print undecorated rate.");
}
};
@@ -78,12 +81,17 @@ struct Client
false);
subs.subscribe(lq, opts.queue);
Message msg;
+ AbsTime begin=now();
for (size_t i = 0; i < opts.count; ++i) {
msg=lq.pop();
QPID_LOG(info, "Received: " << msg.getMessageProperties().getCorrelationId());
}
if (opts.ack != 0)
subs.getAckPolicy().ackOutstanding(session); // Cumulative ack for final batch.
+ AbsTime end=now();
+ double secs(double(Duration(begin,end))/TIME_SEC);
+ if (opts.summary) cout << opts.count/secs << endl;
+ else cout << "Time: " << secs << "s Rate: " << opts.count/secs << endl;
}
~Client()
@@ -91,8 +99,8 @@ struct Client
try{
session.close();
connection.close();
- } catch(const std::exception& e) {
- std::cout << e.what() << std::endl;
+ } catch(const exception& e) {
+ cout << e.what() << endl;
}
}
};
@@ -104,8 +112,8 @@ int main(int argc, char** argv)
Client client;
client.consume();
return 0;
- } catch(const std::exception& e) {
- std::cout << e.what() << std::endl;
+ } catch(const exception& e) {
+ cout << e.what() << endl;
}
return 1;
}