From e3599e88aaa53494ff766ed2b695e2426ddd502c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 4 Sep 2008 12:03:48 +0000 Subject: Fix bug in computing min latency: 0 latencies not handled correctly. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@691985 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/latencytest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cpp/src/tests/latencytest.cpp') diff --git a/cpp/src/tests/latencytest.cpp b/cpp/src/tests/latencytest.cpp index 6f71506d48..524870a0e8 100644 --- a/cpp/src/tests/latencytest.cpp +++ b/cpp/src/tests/latencytest.cpp @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -237,13 +238,13 @@ 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++; + 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::max()), maxLatency(0), totalLatency(0) {} void Stats::print() { -- cgit v1.2.1