Return-Path: Delivered-To: apmail-incubator-qpid-commits-archive@locus.apache.org Received: (qmail 32729 invoked from network); 4 Sep 2008 07:51:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2008 07:51:59 -0000 Received: (qmail 69610 invoked by uid 500); 4 Sep 2008 07:51:57 -0000 Delivered-To: apmail-incubator-qpid-commits-archive@incubator.apache.org Received: (qmail 69601 invoked by uid 500); 4 Sep 2008 07:51:57 -0000 Mailing-List: contact qpid-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: qpid-dev@incubator.apache.org Delivered-To: mailing list qpid-commits@incubator.apache.org Received: (qmail 69592 invoked by uid 99); 4 Sep 2008 07:51:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 00:51:57 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 07:51:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5F88F2388852; Thu, 4 Sep 2008 00:51:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r691900 - /incubator/qpid/trunk/qpid/cpp/src/tests/latencytest.cpp Date: Thu, 04 Sep 2008 07:51:37 -0000 To: qpid-commits@incubator.apache.org From: gsim@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080904075138.5F88F2388852@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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=" <<