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 | 7e8bf419bf18aab8ef31e8e2c94ec0d95ffa6404 (patch) | |
tree | 364304181f218848ee449d53a8832d5e4d7ad81f /qpid/cpp | |
parent | 93b4eb63e30f892955cb33893e931936aac6aa3f (diff) | |
download | qpid-python-7e8bf419bf18aab8ef31e8e2c94ec0d95ffa6404.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@691900 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r-- | qpid/cpp/src/tests/latencytest.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/qpid/cpp/src/tests/latencytest.cpp b/qpid/cpp/src/tests/latencytest.cpp index 6c3fdd23bd..6f71506d48 100644 --- a/qpid/cpp/src/tests/latencytest.cpp +++ b/qpid/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=" << |