summaryrefslogtreecommitdiff
path: root/cpp/src/tests/Statistics.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-04-09 16:06:02 +0000
committerAlan Conway <aconway@apache.org>2010-04-09 16:06:02 +0000
commit2f7e23c2591cc632872bcfc183f0449baf9988e1 (patch)
tree7184e034bee606b0a9e6423a275cc4e0f32d0882 /cpp/src/tests/Statistics.cpp
parent0db7d33b5193a195dbd0cbda3160ed91c107247d (diff)
downloadqpid-python-2f7e23c2591cc632872bcfc183f0449baf9988e1.tar.gz
Script to run performance benchmarks using qpid_send and qpid_receive.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@932479 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Statistics.cpp')
-rw-r--r--cpp/src/tests/Statistics.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/cpp/src/tests/Statistics.cpp b/cpp/src/tests/Statistics.cpp
index 3c5a3a6d4e..bcc646ce46 100644
--- a/cpp/src/tests/Statistics.cpp
+++ b/cpp/src/tests/Statistics.cpp
@@ -21,10 +21,14 @@
#include "Statistics.h"
#include <qpid/messaging/Message.h>
#include <ostream>
+#include <iomanip>
namespace qpid {
namespace tests {
+using namespace std;
+const int WIDTH=10;
+
Statistic::~Statistic() {}
Throughput::Throughput() : messages(0), started(false) {}
@@ -37,19 +41,19 @@ void Throughput::message(const messaging::Message&) {
}
}
-void Throughput::header(std::ostream& o) const {
- o << "msg/sec";
+void Throughput::header(ostream& o) const {
+ o << setw(WIDTH) << "msg/sec";
}
-void Throughput::report(std::ostream& o) const {
+void Throughput::report(ostream& o) const {
double elapsed(int64_t(sys::Duration(start, sys::now()))/double(sys::TIME_SEC));
- o << messages/elapsed;
+ o << setw(WIDTH) << messages/elapsed;
}
ThroughputAndLatency::ThroughputAndLatency() :
total(0),
- min(std::numeric_limits<double>::max()),
- max(std::numeric_limits<double>::min())
+ min(numeric_limits<double>::max()),
+ max(numeric_limits<double>::min())
{}
void ThroughputAndLatency::message(const messaging::Message& m) {
@@ -67,22 +71,25 @@ void ThroughputAndLatency::message(const messaging::Message& m) {
}
}
-void ThroughputAndLatency::header(std::ostream& o) const {
+void ThroughputAndLatency::header(ostream& o) const {
Throughput::header(o);
- o << " latency(ms)min max avg";
+ o << setw(3*WIDTH) << "latency(ms): min max avg";
}
-void ThroughputAndLatency::report(std::ostream& o) const {
+void ThroughputAndLatency::report(ostream& o) const {
Throughput::report(o);
- o << " ";
if (messages)
- o << min << " " << max << " " << total/messages;
+ o << setw(WIDTH) << min << setw(WIDTH) << max << setw(WIDTH) << total/messages;
else
o << "Can't compute latency for 0 messages.";
}
-ReporterBase::ReporterBase(std::ostream& o, int batch)
- : wantBatch(batch), batchCount(0), headerPrinted(false), out(o) {}
+ReporterBase::ReporterBase(ostream& o, int batch)
+ : wantBatch(batch), batchCount(0), headerPrinted(false), out(o)
+{
+ o.precision(2);
+ o << fixed;
+}
ReporterBase::~ReporterBase() {}
@@ -96,7 +103,7 @@ void ReporterBase::message(const messaging::Message& m) {
if (++batchCount == wantBatch) {
header();
batch->report(out);
- out << std::endl;
+ out << endl;
batch = create();
batchCount = 0;
}
@@ -107,14 +114,14 @@ void ReporterBase::message(const messaging::Message& m) {
void ReporterBase::report() {
header();
overall->report(out);
- out << std::endl;
+ out << endl;
}
void ReporterBase::header() {
if (!headerPrinted) {
if (!overall.get()) overall = create();
overall->header(out);
- out << std::endl;
+ out << endl;
headerPrinted = true;
}
}