diff options
author | Gordon Sim <gsim@apache.org> | 2008-09-04 07:51:37 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-09-04 07:51:37 +0000 |
commit | 77c20e7512208a6bbbd637391c5d9958bb7e0753 (patch) | |
tree | 61f40facf8567405483f7672ceee8137898c8475 /cpp/src/tests/latencytest.cpp | |
parent | 835e41a0929ea7e6d70180b6c59605c03daccb13 (diff) | |
download | qpid-python-77c20e7512208a6bbbd637391c5d9958bb7e0753.tar.gz |
Bugfixes:
* handle 0 latencies (possible with low resolution timers) correctly
* calculate average within lock scope to avoid concurrent updates distorting calculation
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@691900 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/latencytest.cpp')
-rw-r--r-- | cpp/src/tests/latencytest.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cpp/src/tests/latencytest.cpp b/cpp/src/tests/latencytest.cpp index 6c3fdd23bd..6f71506d48 100644 --- a/cpp/src/tests/latencytest.cpp +++ b/cpp/src/tests/latencytest.cpp @@ -237,9 +237,9 @@ void Receiver::received(Message& msg) void Stats::update(double latency) { Mutex::ScopedLock l(lock); + if (!count || minLatency > latency) minLatency = latency; + if (!count || maxLatency < latency) maxLatency = latency; count++; - if (minLatency == 0 || minLatency > latency) minLatency = latency; - if (maxLatency == 0 || maxLatency < latency) maxLatency = latency; totalLatency += latency; } @@ -249,13 +249,13 @@ void Stats::print() { static bool already_have_stats = false; uint value; - double aux_avg = (totalLatency / count); if (opts.rate) value = opts.rate; else value = opts.count; Mutex::ScopedLock l(lock); + double aux_avg = (totalLatency / count); if (!opts.cumulative) { if (!opts.csv) { std::cout << "Latency(ms): min=" << minLatency << ", max=" << |