Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 68181 invoked from network); 17 Nov 2006 20:17:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Nov 2006 20:17:56 -0000 Received: (qmail 22862 invoked by uid 500); 17 Nov 2006 20:18:00 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 22842 invoked by uid 500); 17 Nov 2006 20:18:00 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 22803 invoked by uid 99); 17 Nov 2006 20:18:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Nov 2006 12:17:59 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Nov 2006 12:17:48 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 884A71A9846; Fri, 17 Nov 2006 12:17:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r476297 - in /incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf: PerfConsumer.java PerfProducer.java PerfRate.java SimpleTopicTest.java Date: Fri, 17 Nov 2006 20:17:16 -0000 To: activemq-commits@geronimo.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061117201716.884A71A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Fri Nov 17 12:17:15 2006 New Revision: 476297 URL: http://svn.apache.org/viewvc?view=rev&rev=476297 Log: Made PerfRate a more thread safe. Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfRate.java incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java?view=diff&rev=476297&r1=476296&r2=476297 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java (original) +++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java Fri Nov 17 12:17:15 2006 @@ -51,7 +51,7 @@ } public void start() throws JMSException{ connection.start(); - rate.getRate(); + rate.reset(); } public void stop() throws JMSException{ connection.stop(); Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java?view=diff&rev=476297&r1=476296&r2=476297 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java (original) +++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfProducer.java Fri Nov 17 12:17:15 2006 @@ -59,10 +59,10 @@ synchronized public void start() throws JMSException{ if( !running ) { + rate.reset(); running = true; connection.start(); new Thread(this).start(); - rate.reset(); } } public void stop() throws JMSException, InterruptedException{ Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfRate.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfRate.java?view=diff&rev=476297&r1=476296&r2=476297 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfRate.java (original) +++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfRate.java Fri Nov 17 12:17:15 2006 @@ -21,9 +21,11 @@ * @version $Revision: 1.3 $ */ public class PerfRate{ + protected int totalCount; protected int count; protected long startTime=System.currentTimeMillis(); + /** * @return Returns the count. */ @@ -31,7 +33,7 @@ return totalCount; } - public void increment(){ + synchronized public void increment(){ totalCount++; count++; } @@ -41,6 +43,19 @@ long totalTime=endTime-startTime; int result=(int) ((count*1000)/totalTime); return result; + } + + /** + * Resets the rate sampling. + */ + synchronized public PerfRate cloneAndReset() { + PerfRate rc = new PerfRate(); + rc.totalCount = totalCount; + rc.count=count; + rc.startTime=startTime; + count=0; + startTime=System.currentTimeMillis(); + return rc; } /** Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java?view=diff&rev=476297&r1=476296&r2=476297 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java (original) +++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java Fri Nov 17 12:17:15 2006 @@ -43,10 +43,10 @@ //protected String bindAddress="vm://localhost"; protected PerfProducer[] producers; protected PerfConsumer[] consumers; - protected String DESTINATION_NAME=getClass().toString(); + protected String DESTINATION_NAME=getClass().getName(); protected int SAMPLE_COUNT = 30; protected long SAMPLE_INTERVAL = 2000; - protected int NUMBER_OF_CONSUMERS=1; + protected int NUMBER_OF_CONSUMERS=10; protected int NUMBER_OF_PRODUCERS=1; protected int PAYLOAD_SIZE=1024; protected byte[] array=null; @@ -163,27 +163,23 @@ int totalRate=0; int totalCount=0; for(int i=0;i