From d12bd01595f65512f523106fb09570a4ab80a7d1 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 18 Jun 2012 15:19:27 +0000 Subject: QPID-4030: Check send rate actually achieved and report if it fails to match the desired rate git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1351386 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/qpid-latency-test.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/tests/qpid-latency-test.cpp b/qpid/cpp/src/tests/qpid-latency-test.cpp index 20eb4568f3..2343cb1d77 100644 --- a/qpid/cpp/src/tests/qpid-latency-test.cpp +++ b/qpid/cpp/src/tests/qpid-latency-test.cpp @@ -359,19 +359,29 @@ void Sender::sendByRate() } uint64_t interval = TIME_SEC/opts.rate; int64_t timeLimit = opts.timeLimit * TIME_SEC; - uint64_t sent = 0, missedRate = 0; + uint64_t sent = 0; AbsTime start = now(); + AbsTime last = start; while (true) { AbsTime sentAt=now(); msg.getDeliveryProperties().setTimestamp(Duration(EPOCH, sentAt)); async(session).messageTransfer(arg::content=msg, arg::acceptMode=1); if (opts.sync) session.sync(); ++sent; + if (Duration(last, sentAt) > TIME_SEC*2) { + Duration t(start, now()); + //check rate actually achieved thus far + uint actualRate = sent / (t/TIME_SEC); + //report inability to stay within 1% of desired rate + if (actualRate < opts.rate && opts.rate - actualRate > opts.rate/100) { + std::cerr << "WARNING: Desired send rate: " << opts.rate << ", actual send rate: " << actualRate << std::endl; + } + last = sentAt; + } + AbsTime waitTill(start, sent*interval); Duration delay(sentAt, waitTill); - if (delay < 0) - ++missedRate; - else + if (delay > 0) sys::usleep(delay / TIME_USEC); if (timeLimit != 0 && Duration(start, now()) > timeLimit) { session.sync(); -- cgit v1.2.1