summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-04-21 14:48:48 +0000
committerAlan Conway <aconway@apache.org>2010-04-21 14:48:48 +0000
commite9c27048f9538d7484f9537e43f357df5f20b4e1 (patch)
treec02d933f7560848aac5d1bc312c8ec9b1b852249
parentcf64f06ddfb2ca381afd8ce6b85095b74921d494 (diff)
downloadqpid-python-e9c27048f9538d7484f9537e43f357df5f20b4e1.tar.gz
Count latency samples, don't assume all messages are latency samples.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@936336 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/tests/Statistics.cpp11
-rw-r--r--qpid/cpp/src/tests/Statistics.h1
2 files changed, 8 insertions, 4 deletions
diff --git a/qpid/cpp/src/tests/Statistics.cpp b/qpid/cpp/src/tests/Statistics.cpp
index a3852e64af..c002bc6a6a 100644
--- a/qpid/cpp/src/tests/Statistics.cpp
+++ b/qpid/cpp/src/tests/Statistics.cpp
@@ -52,13 +52,15 @@ void Throughput::report(ostream& o) const {
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(ostream& o) const {
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)
diff --git a/qpid/cpp/src/tests/Statistics.h b/qpid/cpp/src/tests/Statistics.h
index 90bdbb6819..091046a17f 100644
--- a/qpid/cpp/src/tests/Statistics.h
+++ b/qpid/cpp/src/tests/Statistics.h
@@ -68,6 +68,7 @@ class ThroughputAndLatency : public Throughput {
private:
double total, min, max; // Milliseconds
+ int samples;
};
/** Report batch and overall statistics */