summaryrefslogtreecommitdiff
path: root/cpp/src/tests/Statistics.cpp
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
commitb7c74d4a77f802b5ec5b6177009f0a2937bde201 (patch)
treeb6e2d4db71ce7533332d3913982975737fb46d9c /cpp/src/tests/Statistics.cpp
parent6deafcfa75ece1e86569ddcb40ccc3004e607154 (diff)
downloadqpid-python-b7c74d4a77f802b5ec5b6177009f0a2937bde201.tar.gz
Count latency samples, don't assume all messages are latency samples.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@936336 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Statistics.cpp')
-rw-r--r--cpp/src/tests/Statistics.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/cpp/src/tests/Statistics.cpp b/cpp/src/tests/Statistics.cpp
index a3852e64af..c002bc6a6a 100644
--- a/cpp/src/tests/Statistics.cpp
+++ b/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)