summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-04-13 17:43:02 +0000
committerAlan Conway <aconway@apache.org>2010-04-13 17:43:02 +0000
commitb8a284439c00e81c21307f651c71f8256ae725f9 (patch)
treedcd1a247483fb99df4c72dc78ae5a29e5e74e454 /cpp/src/tests
parenta41bff40eb9080aa99a06b5325d47d995079d5a0 (diff)
downloadqpid-python-b8a284439c00e81c21307f651c71f8256ae725f9.tar.gz
Make qpid_send/qpid_receive output more spreadsheet-friendly.
- output is tab separated - --report-header=no suppresses headers git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@933718 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/Statistics.cpp23
-rw-r--r--cpp/src/tests/Statistics.h9
-rw-r--r--cpp/src/tests/qpid_receive.cpp8
-rw-r--r--cpp/src/tests/qpid_send.cpp5
4 files changed, 24 insertions, 21 deletions
diff --git a/cpp/src/tests/Statistics.cpp b/cpp/src/tests/Statistics.cpp
index bcc646ce46..87cab2926c 100644
--- a/cpp/src/tests/Statistics.cpp
+++ b/cpp/src/tests/Statistics.cpp
@@ -27,7 +27,6 @@ namespace qpid {
namespace tests {
using namespace std;
-const int WIDTH=10;
Statistic::~Statistic() {}
@@ -42,12 +41,12 @@ void Throughput::message(const messaging::Message&) {
}
void Throughput::header(ostream& o) const {
- o << setw(WIDTH) << "msg/sec";
+ o << "tp(m/s)";
}
void Throughput::report(ostream& o) const {
double elapsed(int64_t(sys::Duration(start, sys::now()))/double(sys::TIME_SEC));
- o << setw(WIDTH) << messages/elapsed;
+ o << fixed << setprecision(0) << messages/elapsed;
}
ThroughputAndLatency::ThroughputAndLatency() :
@@ -73,23 +72,21 @@ void ThroughputAndLatency::message(const messaging::Message& m) {
void ThroughputAndLatency::header(ostream& o) const {
Throughput::header(o);
- o << setw(3*WIDTH) << "latency(ms): min max avg";
+ o << '\t' << "l-min" << '\t' << "l-max" << '\t' << "l-avg";
}
void ThroughputAndLatency::report(ostream& o) const {
Throughput::report(o);
if (messages)
- o << setw(WIDTH) << min << setw(WIDTH) << max << setw(WIDTH) << total/messages;
+ o << fixed << setprecision(2)
+ << '\t' << min << '\t' << max << '\t' << total/messages;
else
o << "Can't compute latency for 0 messages.";
}
-ReporterBase::ReporterBase(ostream& o, int batch)
- : wantBatch(batch), batchCount(0), headerPrinted(false), out(o)
-{
- o.precision(2);
- o << fixed;
-}
+ReporterBase::ReporterBase(ostream& o, int batch, bool wantHeader)
+ : batchSize(batch), batchCount(0), headerPrinted(!wantHeader), out(o)
+{}
ReporterBase::~ReporterBase() {}
@@ -97,10 +94,10 @@ ReporterBase::~ReporterBase() {}
void ReporterBase::message(const messaging::Message& m) {
if (!overall.get()) overall = create();
overall->message(m);
- if (wantBatch) {
+ if (batchSize) {
if (!batch.get()) batch = create();
batch->message(m);
- if (++batchCount == wantBatch) {
+ if (++batchCount == batchSize) {
header();
batch->report(out);
out << endl;
diff --git a/cpp/src/tests/Statistics.h b/cpp/src/tests/Statistics.h
index def37b7424..90bdbb6819 100644
--- a/cpp/src/tests/Statistics.h
+++ b/cpp/src/tests/Statistics.h
@@ -82,7 +82,7 @@ class ReporterBase {
void report();
protected:
- ReporterBase(std::ostream& o, int batchSize);
+ ReporterBase(std::ostream& o, int batchSize, bool wantHeader);
virtual std::auto_ptr<Statistic> create() = 0;
private:
@@ -90,15 +90,16 @@ class ReporterBase {
void report(const Statistic& s);
std::auto_ptr<Statistic> overall;
std::auto_ptr<Statistic> batch;
- bool wantOverall;
- int wantBatch, batchCount;
+ int batchSize, batchCount;
bool stopped, headerPrinted;
std::ostream& out;
};
template <class Stats> class Reporter : public ReporterBase {
public:
- Reporter(std::ostream& o, int batchSize) : ReporterBase(o, batchSize) {}
+ Reporter(std::ostream& o, int batchSize, bool wantHeader)
+ : ReporterBase(o, batchSize, wantHeader) {}
+
virtual std::auto_ptr<Statistic> create() {
return std::auto_ptr<Statistic>(new Stats);
}
diff --git a/cpp/src/tests/qpid_receive.cpp b/cpp/src/tests/qpid_receive.cpp
index d67232ad86..4c0d8c74c2 100644
--- a/cpp/src/tests/qpid_receive.cpp
+++ b/cpp/src/tests/qpid_receive.cpp
@@ -64,6 +64,7 @@ struct Options : public qpid::Options
qpid::log::Options log;
bool reportTotal;
uint reportEvery;
+ bool reportHeader;
string readyAddress;
Options(const std::string& argv0=std::string())
@@ -83,7 +84,8 @@ struct Options : public qpid::Options
failoverUpdates(false),
log(argv0),
reportTotal(false),
- reportEvery(0)
+ reportEvery(0),
+ reportHeader(true)
{
addOptions()
("broker,b", qpid::optValue(url, "URL"), "url of broker to connect to")
@@ -102,7 +104,7 @@ struct Options : public qpid::Options
("failover-updates", qpid::optValue(failoverUpdates), "Listen for membership updates distributed via amq.failover")
("report-total", qpid::optValue(reportTotal), "Report total throughput and latency statistics")
("report-every", qpid::optValue(reportEvery,"N"), "Report throughput and latency statistics every N messages.")
- ("ready-address", qpid::optValue(readyAddress, "ADDRESS"),
+ ("report-header", qpid::optValue(reportHeader, "yes|no"), "Headers on report.") ("ready-address", qpid::optValue(readyAddress, "ADDRESS"),
"send a message to this address when ready to receive")
("help", qpid::optValue(help), "print this usage statement");
add(log);
@@ -176,7 +178,7 @@ int main(int argc, char ** argv)
SequenceTracker sequenceTracker;
Duration timeout = opts.getTimeout();
bool done = false;
- Reporter<ThroughputAndLatency> reporter(std::cout, opts.reportEvery);
+ Reporter<ThroughputAndLatency> reporter(std::cout, opts.reportEvery, opts.reportHeader);
if (!opts.readyAddress.empty())
session.createSender(opts.readyAddress).send(msg);
while (!done && receiver.fetch(msg, timeout)) {
diff --git a/cpp/src/tests/qpid_send.cpp b/cpp/src/tests/qpid_send.cpp
index 08210da7ee..ec6586323f 100644
--- a/cpp/src/tests/qpid_send.cpp
+++ b/cpp/src/tests/qpid_send.cpp
@@ -69,6 +69,7 @@ struct Options : public qpid::Options
qpid::log::Options log;
bool reportTotal;
uint reportEvery;
+ bool reportHeader;
uint rate;
Options(const std::string& argv0=std::string())
@@ -89,6 +90,7 @@ struct Options : public qpid::Options
log(argv0),
reportTotal(false),
reportEvery(0),
+ reportHeader(true),
rate(0)
{
addOptions()
@@ -114,6 +116,7 @@ struct Options : public qpid::Options
("failover-updates", qpid::optValue(failoverUpdates), "Listen for membership updates distributed via amq.failover")
("report-total", qpid::optValue(reportTotal), "Report total throughput statistics")
("report-every", qpid::optValue(reportEvery,"N"), "Report throughput statistics every N messages")
+ ("report-header", qpid::optValue(reportHeader, "yes|no"), "Headers on report.")
("rate", qpid::optValue(rate,"N"), "Send at rate of N messages/second. 0 means send as fast as possible.")
("help", qpid::optValue(help), "print this usage statement");
add(log);
@@ -256,7 +259,7 @@ int main(int argc, char ** argv)
opts.setProperties(msg);
uint sent = 0;
uint txCount = 0;
- Reporter<Throughput> reporter(std::cout, opts.reportEvery);
+ Reporter<Throughput> reporter(std::cout, opts.reportEvery, opts.reportHeader);
std::auto_ptr<ContentGenerator> contentGen;
if (opts.contentStdin) {