qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r691900 - /incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp
Date Thu, 04 Sep 2008 07:51:37 GMT
Author: gsim
Date: Thu Sep  4 00:51:37 2008
New Revision: 691900

URL: http://svn.apache.org/viewvc?rev=691900&view=rev
Log:
Bugfixes:
* handle 0 latencies (possible with low resolution timers) correctly
* calculate average within lock scope to avoid concurrent updates distorting calculation


Modified:
    incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp?rev=691900&r1=691899&r2=691900&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp Thu Sep  4 00:51:37 2008
@@ -237,9 +237,9 @@
 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 @@
 {
     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="
<<



Mime
View raw message