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/21 16:48:49 UTC

svn commit: r936336 - in /qpid/trunk/qpid/cpp/src/tests: Statistics.cpp Statistics.h

Author: aconway
Date: Wed Apr 21 14:48:48 2010
New Revision: 936336

URL: http://svn.apache.org/viewvc?rev=936336&view=rev
Log:
Count latency samples, don't assume all messages are latency samples.

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

Modified: qpid/trunk/qpid/cpp/src/tests/Statistics.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Statistics.cpp?rev=936336&r1=936335&r2=936336&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/Statistics.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/Statistics.cpp Wed Apr 21 14:48:48 2010
@@ -52,13 +52,15 @@ void Throughput::report(ostream& o) cons
 ThroughputAndLatency::ThroughputAndLatency() :
     total(0),
     min(numeric_limits<double>::max()),
-    max(numeric_limits<double>::min())
+    max(numeric_limits<double>::min()),
+    samples(0)
 {}
 
 void ThroughputAndLatency::message(const messaging::Message& m) {
     Throughput::message(m);
     types::Variant::Map::const_iterator i = m.getProperties().find("ts");
     if (i != m.getProperties().end()) {
+        ++samples;
         int64_t start(i->second.asInt64());
         int64_t end(sys::Duration(sys::EPOCH, sys::now()));
         double latency = double(end - start)/sys::TIME_MSEC;
@@ -77,11 +79,12 @@ void ThroughputAndLatency::header(ostrea
 
 void ThroughputAndLatency::report(ostream& o) const {
     Throughput::report(o);
-    if (messages)
+    if (samples) {
         o << fixed << setprecision(2)
-          << '\t' << min << '\t'  << max << '\t' << total/messages;
+          << '\t' << min << '\t'  << max << '\t' << total/samples;
+    }
     else
-        o << "\t<0 messages, can't compute latency>";
+        o << "\t[No latency samples]";
 }
 
 ReporterBase::ReporterBase(ostream& o, int batch, bool wantHeader)

Modified: qpid/trunk/qpid/cpp/src/tests/Statistics.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/Statistics.h?rev=936336&r1=936335&r2=936336&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/Statistics.h (original)
+++ qpid/trunk/qpid/cpp/src/tests/Statistics.h Wed Apr 21 14:48:48 2010
@@ -68,6 +68,7 @@ class ThroughputAndLatency : public Thro
 
   private:
     double total, min, max;     // Milliseconds
+    int samples;
 };
 
 /** Report batch and overall statistics */



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