[jboss-svn-commits] JBL Code SVN: r32341 - 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 Apr 1 10:27:16 EDT 2010
Author: whitingjr
Date: 2010-04-01 10:27:16 -0400 (Thu, 01 Apr 2010)
New Revision: 32341
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:
Refactored to log the results to file.
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-04-01 14:24:51 UTC (rev 32340)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/MultiThreadedTest.java 2010-04-01 14:27:16 UTC (rev 32341)
@@ -10,13 +10,15 @@
public abstract class MultiThreadedTest extends MultiResourceTest
{
private static final Logger logger = Logger.getLogger(MultiThreadedTest.class);
-
+
+ private static final Logger csvLogger = Logger.getLogger("csv.file.logger");
+
/**
* 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.
*/
@Override
- public void startConcurrentExecutions(final TestConfiguration configuration)
+ public void startConcurrentExecutions(final TestConfiguration configuration, final boolean printSummary)
throws Exception
{
/**
@@ -28,42 +30,51 @@
* remains active during all spawned threads are processing.
*/
CyclicBarrier completionBarrier = new CyclicBarrier(1 + configuration.getThreadCount()); // this shared between threads
-
+
for (int count = 1; count <= configuration.getThreadCount(); count += 1)
{
Executor executor = new ThreadPerTestWorkerExecutor();
/* 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), configuration.getThreadResults(), getConnectionHandlerClass()) ));
+ executor.execute(getTask(new MultithreadedTestConfiguration(configuration.getIterationCount(),
+ completionBarrier, new Long(count), configuration.getThreadResults(), getConnectionHandlerClass())));
}
-
- while(completionBarrier.getNumberWaiting() < configuration.getThreadCount())
+
+ while (completionBarrier.getNumberWaiting() < configuration.getThreadCount())
{
Thread.sleep(100);
}
long start = System.currentTimeMillis();
completionBarrier.await();// start all the threads processing
-
+
logger.info("All threads have started processing.");
if (!completionBarrier.isBroken())
{
// good, worked so far, now wait for completion of tests
-
+
completionBarrier.await();// all threads fall out, either by assertion error or all iterations completing
-
- long duration = System.currentTimeMillis() - start;
- float timeInSecs = duration / 1000;
+
+ long durationMilli = System.currentTimeMillis() - start;
+ long durationNano = durationMilli * 1000;
+ float timeInSecs = durationMilli / 1000;
float txPerSec = (configuration.getThreadCount() * configuration.getIterationCount()) / timeInSecs;
+ int tx = (configuration.getThreadCount() * configuration.getIterationCount());
logger.info(String.format("TxPerSec:%1$.0f", txPerSec));
logger.info(String.format("TimeInSecs:%1$.2f", timeInSecs));
logger.info(String.format("Tx:%1$d", (configuration.getThreadCount() * configuration.getIterationCount())));
-
- // wait for all to finish profiled run
+
+ if (printSummary)
+ {
+ this.csvLogger.debug("#threads, TimeInNano, TimePerTx, TxPerSec, TimeInSecs, Tx");
+ this.csvLogger.debug(String.format("%1$d, %2$d, %3$d, %4$.0f, %5$.0f, %6$d", configuration
+ .getThreadCount(), durationNano, (durationNano) / tx, txPerSec, timeInSecs, tx));
+ }
}
else
{
- logger.warn("The controlling test class did not await for child threads. The co-ordinating barrier was broken.");
+ logger
+ .warn("The controlling test class did not await for child threads. The co-ordinating barrier was broken.");
}
}
}
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-04-01 14:24:51 UTC (rev 32340)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java 2010-04-01 14:27:16 UTC (rev 32341)
@@ -46,7 +46,7 @@
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");
+ //private static final Logger csvLogger = Logger.getLogger("csv.file.logger");
@Test(groups = "integration-warmup")
@Parameters(
@@ -56,7 +56,7 @@
{
NDC.push("warmup");
int threadCount = Integer.parseInt(threadCountConfig);
- startConcurrentExecutions(new TestConfiguration(Integer.parseInt(warmupCountConfig), threadCount, null));
+ startConcurrentExecutions(new TestConfiguration(Integer.parseInt(warmupCountConfig), threadCount, null), false);
NDC.remove();
}
@@ -77,8 +77,8 @@
}
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);
+ startConcurrentExecutions(new TestConfiguration(Integer.parseInt(testCountConfig), Integer.parseInt(concurrentCountConfig), results), true);
+ //logResults(results, threadCount, Integer.parseInt(testCountConfig));
try
{
getProfiler().stop();
@@ -92,18 +92,25 @@
/*
* 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.
+ * format: thread count, average per thread, tx per second, time (in seconds), tx
*/
- private void logResults(List<Long> results, Integer threadCount)
+ private void logResults(List<Long> results, Integer threadCount, Integer testCount)
{
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)));
- }
+ long average = total / threadCount;
+ float timeInSecs = total / 1000;
+ int tx = threadCount * testCount;
+ float txPerSec = tx / timeInSecs;
+
+ //this.csvLogger.debug(String.format("%1$d,%2$d,%3$f,%4$f,%5$d", threadCount, average, txPerSec, timeInSecs, tx));
+ }*/
}
/**
@@ -113,7 +120,7 @@
* @param threadCount
* @throws Exception
*/
- public abstract void startConcurrentExecutions(final TestConfiguration configuration) throws Exception;
+ public abstract void startConcurrentExecutions(final TestConfiguration configuration, final boolean printSummary) throws Exception;
public abstract Runnable getTask(final MultithreadedTestConfiguration taskConfiguration) throws Exception;
More information about the jboss-svn-commits
mailing list