You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2010/04/13 19:43:02 UTC

svn commit: r933718 - in /qpid/trunk/qpid/cpp/src/tests: Statistics.cpp Statistics.h qpid_receive.cpp qpid_send.cpp

Author: aconway
Date: Tue Apr 13 17:43:02 2010
New Revision: 933718

URL: http://svn.apache.org/viewvc?rev=933718&view=rev
Log:
Make qpid_send/qpid_receive output more spreadsheet-friendly.

- output is tab separated
- --report-header=no suppresses headers

Modified:
    qpid/trunk/qpid/cpp/src/tests/Statistics.cpp
    qpid/trunk/qpid/cpp/src/tests/Statistics.h
    qpid/trunk/qpid/cpp/src/tests/qpid_receive.cpp
    qpid/trunk/qpid/cpp/src/tests/qpid_send.cpp

Modified: qpid/trunk/qpid/cpp/src/tests/Statistics.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Statistics.cpp?rev=933718&r1=933717&r2=933718&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/Statistics.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/Statistics.cpp Tue Apr 13 17:43:02 2010
@@ -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
 }
 
 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
 
 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;

Modified: qpid/trunk/qpid/cpp/src/tests/Statistics.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Statistics.h?rev=933718&r1=933717&r2=933718&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/Statistics.h (original)
+++ qpid/trunk/qpid/cpp/src/tests/Statistics.h Tue Apr 13 17:43:02 2010
@@ -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);
     }

Modified: qpid/trunk/qpid/cpp/src/tests/qpid_receive.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/qpid_receive.cpp?rev=933718&r1=933717&r2=933718&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/qpid_receive.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/qpid_receive.cpp Tue Apr 13 17:43:02 2010
@@ -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)) {

Modified: qpid/trunk/qpid/cpp/src/tests/qpid_send.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/qpid_send.cpp?rev=933718&r1=933717&r2=933718&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/qpid_send.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/qpid_send.cpp Tue Apr 13 17:43:02 2010
@@ -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) {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org