[jboss-svn-commits] JBL Code SVN: r31723 - labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 18 06:09:06 EST 2010


Author: whitingjr
Date: 2010-02-18 06:09:05 -0500 (Thu, 18 Feb 2010)
New Revision: 31723

Modified:
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java
Log:
Updated to allow basic timing measuring.

Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java	2010-02-18 11:08:36 UTC (rev 31722)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java	2010-02-18 11:09:05 UTC (rev 31723)
@@ -10,6 +10,7 @@
 public abstract class MultiThreadedTest extends MultiResourceTest
 {
    private static final Logger logger = Logger.getLogger(MultiThreadedTest.class);
+   
    /**
     * Use this method to start concurrent executions of the test. This should be used for
     * initial warm up run of the compiler and stable runs.
@@ -34,7 +35,7 @@
          /* Here we use the count value as the threadIdentity. This allows each thread to 
           * use (read/write) a record in the database that does not overlap with other threads. 
           * Avoiding deadlocking in the database. */
-         executor.execute(getTask( new MultithreadedTestConfiguration(configuration.getIterationCount(), completionBarrier, new Long(count)) ));
+         executor.execute(getTask( new MultithreadedTestConfiguration(configuration.getIterationCount(), completionBarrier, new Long(count), configuration.getThreadResults()) ));
       }
       completionBarrier.await();// start all the threads processing
       long start = System.currentTimeMillis(); 

Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java	2010-02-18 11:08:36 UTC (rev 31722)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java	2010-02-18 11:09:05 UTC (rev 31723)
@@ -22,6 +22,9 @@
 
 package org.jboss.jbossts.performance;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.concurrent.Executor;
 
 import org.apache.log4j.Logger;
@@ -37,13 +40,13 @@
  * The purpose of this object is to run the test case several times to warm up
  * the compiler.
  * 
- * @author whitingjr
+ * @author whitingjr Jeremy Whiting
  * 
  */
 public abstract class WarmedUpTest extends ProfiledStateTransitions 
 {
    private static final Logger logger = Logger.getLogger(WarmedUpTest.class);
-   
+   private static final Logger csvLogger = Logger.getLogger("csv.file.logger");
 
    @Test(groups = "integration-warmup")
    @Parameters(
@@ -52,7 +55,8 @@
       throws Exception
    {
       NDC.push("warmup");
-      startConcurrentExecutions(new TestConfiguration(Integer.parseInt(warmupCountConfig), Integer.parseInt(threadCountConfig)));
+      int threadCount = Integer.parseInt(threadCountConfig);
+      startConcurrentExecutions(new TestConfiguration(Integer.parseInt(warmupCountConfig), threadCount, null));
       NDC.remove();
    }
 
@@ -71,7 +75,10 @@
       {
          logger.warn(e.getMessage());
       }
-      startConcurrentExecutions(new TestConfiguration(Integer.parseInt(testCountConfig), Integer.parseInt(concurrentCountConfig)));
+      int threadCount = Integer.parseInt(concurrentCountConfig);
+      List<Long> results = Collections.synchronizedList(new ArrayList<Long>(threadCount));
+      startConcurrentExecutions(new TestConfiguration(Integer.parseInt(testCountConfig), Integer.parseInt(concurrentCountConfig), results));
+      logResults(results, threadCount);
       try
       {
          getProfiler().stop();
@@ -82,6 +89,23 @@
       NDC.remove();
    }
    
+   /*
+    * This method will log the results to file. The method takes all the results and devides
+    * by the number of threads to calculate an average amount.
+    */
+   private void logResults(List<Long> results, Integer threadCount)
+   {
+      long total = 0l;
+      for(Long result : results)
+      {
+         total += result;
+      }
+      if (this.csvLogger.isDebugEnabled())
+      {
+         this.csvLogger.debug(String.format("%1$d,%2$d", threadCount, (total/threadCount)));
+      }
+   }
+   
    /**
     * The implementing method has to fulfil the contract that before the method
     * completes all threads will have finished their work.



More information about the jboss-svn-commits mailing list