qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r691985 - /incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp
Date Thu, 04 Sep 2008 12:03:48 GMT
Author: aconway
Date: Thu Sep  4 05:03:48 2008
New Revision: 691985

URL: http://svn.apache.org/viewvc?rev=691985&view=rev
Log:
Fix bug in computing min latency: 0 latencies not handled correctly.

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=691985&r1=691984&r2=691985&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp Thu Sep  4 05:03:48 2008
@@ -21,6 +21,7 @@
 
 
 #include <algorithm>
+#include <limits>
 #include <iostream>
 #include <memory>
 #include <sstream>
@@ -237,13 +238,13 @@
 void Stats::update(double latency)
 {
     Mutex::ScopedLock l(lock);
-    if (!count || minLatency > latency) minLatency = latency;
-    if (!count || maxLatency < latency) maxLatency = latency;
     count++;
+    minLatency = std::min(minLatency, latency);
+    maxLatency = std::max(maxLatency, latency);
     totalLatency += latency;
 }
 
-Stats::Stats() : count(0), minLatency(0), maxLatency(0), totalLatency(0) {}
+Stats::Stats() : count(0), minLatency(std::numeric_limits<double>::max()), maxLatency(0),
totalLatency(0) {}
 
 void Stats::print()
 {



Mime
View raw message