[jboss-cvs] JBoss Messaging SVN: r4280 - in trunk/examples/jms: src/org/jboss/jms/example and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 22 05:21:57 EDT 2008


Author: jmesnil
Date: 2008-05-22 05:21:57 -0400 (Thu, 22 May 2008)
New Revision: 4280

Modified:
   trunk/examples/jms/build.xml
   trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java
   trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java
Log:
* when computing the average, ignore the first 4 samples (warmup time)
* expressed all the time attributes in seconds

Modified: trunk/examples/jms/build.xml
===================================================================
--- trunk/examples/jms/build.xml	2008-05-22 03:55:39 UTC (rev 4279)
+++ trunk/examples/jms/build.xml	2008-05-22 09:21:57 UTC (rev 4280)
@@ -43,6 +43,7 @@
    <!--perf props-->
    <property name="message.count" value="200000"/>
    <property name="delivery.mode" value="NON_PERSISTENT"/>
+	<!-- in seconds -->
    <property name="sample.period" value="1"/>
    <property name="sess.trans" value="false"/>
    <property name="sess.trans.size" value="1"/>

Modified: trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java
===================================================================
--- trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java	2008-05-22 03:55:39 UTC (rev 4279)
+++ trunk/examples/jms/src/org/jboss/jms/example/PerfExample.java	2008-05-22 09:21:57 UTC (rev 4280)
@@ -122,7 +122,7 @@
             session.commit();
          }
          scheduler.shutdownNow();
-         log.info("average " +  command.getAverage() + " per " + (perfParams.getSamplePeriod()/1000) + " secs" );
+         log.info("average " +  command.getAverage() + " per " + perfParams.getSamplePeriod() + " secs" );
       }
       catch (Exception e)
       {
@@ -222,7 +222,7 @@
                }
                countDownLatch.countDown();
                scheduler.shutdownNow();
-               log.info("average " +  command.getAverage() + " per sec" );
+               log.info("average: " +  command.getAverage() + " msg/s" );
             }
          }
          catch (Exception e)
@@ -251,28 +251,44 @@
     */
    class Sampler implements Runnable
    {
+      private static final int IGNORED_SAMPLES = 4;
+      
       int sampleCount = 0;
-
+      int ignoredCount = 0;
+      
       long startTime = 0;
 
       long samplesTaken = 0;
 
       public void run()
-      {
+      {         
          if(startTime == 0)
          {
             startTime = System.currentTimeMillis();
          }
-         long elapsed = System.currentTimeMillis() - startTime;
+         long elapsed = (System.currentTimeMillis() - startTime) / 1000; // in s
          int lastCount = sampleCount;
          sampleCount = messageCount;
+         if (samplesTaken >= IGNORED_SAMPLES)
+         {
+            info(elapsed, sampleCount, sampleCount - lastCount, false);
+         } else {
+            info(elapsed, sampleCount, sampleCount - lastCount, true);
+            ignoredCount += (sampleCount - lastCount);            
+         }
          samplesTaken++;
-         log.info(" time elapsed " + (elapsed / 1000) + " secs, message count " + (sampleCount) + " : this period " + (sampleCount - lastCount));
       }
 
+      public void info(long elapsedTime, int totalCount, int sampleCount, boolean ignored)
+      {
+         String message = String.format("time elapsed: %2ds, message count: %7d, this period: %5d %s", 
+               elapsedTime, totalCount, sampleCount, ignored ? "[IGNORED]" : "");
+         log.info(message);
+      }
+      
       public long getAverage()
       {
-         return sampleCount/samplesTaken;
+         return (sampleCount - ignoredCount)/(samplesTaken - IGNORED_SAMPLES);
       }
 
    }

Modified: trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java
===================================================================
--- trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java	2008-05-22 03:55:39 UTC (rev 4279)
+++ trunk/examples/jms/src/org/jboss/jms/util/PerfParams.java	2008-05-22 09:21:57 UTC (rev 4280)
@@ -30,7 +30,7 @@
 public class PerfParams implements Serializable
 {
    int noOfMessagesToSend = 1000;
-   long samplePeriod = 1000;
+   long samplePeriod = 1; // in seconds
    int deliveryMode  = DeliveryMode.NON_PERSISTENT;
    boolean isSessionTransacted = false;
    int transactionBatchSize = 5000;
@@ -88,7 +88,7 @@
 
    public String toString()
    {
-      return "message to send = " + noOfMessagesToSend + " samplePeriod = " + samplePeriod + "ms" + " DeliveryMode = " +
+      return "message to send = " + noOfMessagesToSend + " samplePeriod = " + samplePeriod + "s" + " DeliveryMode = " +
               (deliveryMode == DeliveryMode.PERSISTENT?"PERSISTENT":"NON_PERSISTENT") + " session transacted = " + isSessionTransacted +
               (isSessionTransacted?" transaction batch size = " + transactionBatchSize:"");
    }




More information about the jboss-cvs-commits mailing list