summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-05-28 15:29:42 +0000
committerGordon Sim <gsim@apache.org>2008-05-28 15:29:42 +0000
commite23360e9444e12aa1031d378d254ce0a9d4e45ea (patch)
tree57b038f7b9bc9076f5bc5c5c23b722c70014ab40 /cpp/src
parenta01cfe5a6ad7fdd519e88d2dd3d3ebc1e96d2445 (diff)
downloadqpid-python-e23360e9444e12aa1031d378d254ce0a9d4e45ea.tar.gz
Improve latency test tool to allow lower rates.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@660981 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/tests/latencytest.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/cpp/src/tests/latencytest.cpp b/cpp/src/tests/latencytest.cpp
index f4cbade36b..ba354c1c17 100644
--- a/cpp/src/tests/latencytest.cpp
+++ b/cpp/src/tests/latencytest.cpp
@@ -212,6 +212,7 @@ void Receiver::received(Message& msg)
//uint64_t sentAt = msg.getHeaders().getTimestamp("sent-at");// TODO: add support for uint64_t as a field table type
uint64_t receivedAt = current_time();
+ //std::cerr << "Latency: " << (receivedAt - sentAt) << std::endl;
stats.update(((double) (receivedAt - sentAt)) / TIME_MSEC);
if (!opts.rate && count >= opts.count) {
@@ -274,24 +275,21 @@ void Sender::sendByRate()
msg.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
}
- //calculate metrics required for target rate
- uint msgsPerMsec = opts.rate / 1000;
+ //calculate interval (in micro secs) between messages to achieve desired rate
+ uint64_t interval = (1000*1000)/opts.rate;
while (true) {
uint64_t start(current_time());
- for (uint i = 0; i < msgsPerMsec; i++) {
- uint64_t sentAt(current_time());
- msg.getDeliveryProperties().setTimestamp(sentAt);
- //msg.getHeaders().setTimestamp("sent-at", sentAt);//TODO add support for uint64_t to field tables
- async(session).messageTransfer(arg::content=msg, arg::acceptMode=1);
- }
+ msg.getDeliveryProperties().setTimestamp(start);
+ //msg.getHeaders().setTimestamp("sent-at", sentAt);//TODO add support for uint64_t to field tables
+ async(session).messageTransfer(arg::content=msg, arg::acceptMode=1);
+
uint64_t timeTaken = (current_time() - start) / TIME_USEC;
- if (timeTaken < 1000) {
- usleep(1000 - timeTaken);
- } else if (timeTaken > 1000) {
- double timeMsecs = (double) timeTaken / 1000;
- std::cout << "Could not achieve desired rate. Sent " << msgsPerMsec << " in "
- << (timeMsecs) << "ms (" << ((msgsPerMsec * 1000 * 1000) / timeTaken) << " msgs/s)" << std::endl;
+ if (timeTaken < interval) {
+ usleep(interval - timeTaken);
+ } else if (timeTaken > interval) {
+ std::cout << "Could not achieve desired rate! (Took " << timeTaken
+ << " microsecs to send message, aiming for " << interval << " microsecs)" << std::endl;
}
}
}