[jboss-svn-commits] JBL Code SVN: r31726 - labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 18 06:10:54 EST 2010
Author: whitingjr
Date: 2010-02-18 06:10:53 -0500 (Thu, 18 Feb 2010)
New Revision: 31726
Modified:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java
Log:
Updated to allow basic timing measuring.
Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java 2010-02-18 11:10:31 UTC (rev 31725)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/RecursiveTask.java 2010-02-18 11:10:53 UTC (rev 31726)
@@ -27,6 +27,7 @@
import javax.persistence.EntityManagerFactory;
+import org.apache.commons.lang.mutable.MutableLong;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
import org.jboss.jbossts.performance.configuration.ConcurrentTaskConfiguration;
@@ -74,11 +75,20 @@
NDC.inherit(this.parentNDC);
NDC.push(this.threadId.toString());
this.completionBarrier.await();// await all threads ready to start
- recurse(this.recurseCount);
- logger.info("Finished recursing. Awaiting on synch point.");
+ MutableLong totalTime = recurse(this.recurseCount);
+ if (logger.isInfoEnabled())
+ {
+ logger.info("Finished recursing. Awaiting on synch point.");
+ }
if (!this.completionBarrier.isBroken())
{// fall out of thread without waiting.
+ if (null != this.taskConfiguration.getThreadResults())
+ {
+ /* Put into the results object a value. The value is the average time for
+ * this thread to execute the task. */
+ this.taskConfiguration.getThreadResults().add(( totalTime.toLong()/this.recurseCount));// serialized modification, insertion order not important
+ }
this.completionBarrier.await();// await all threads have finished
}
}
@@ -105,14 +115,20 @@
*
* @param count
*/
- private void recurse(final int count)
+ private MutableLong recurse(final int count)
{
+ MutableLong returnValue = new MutableLong();
for (int i = 0; i < count; i += 1)
{
try
{
+ long start = System.nanoTime();
task(i);
- logger.debug(String.format("Completed profiled run of testbody for thread [%1$d] count [%2$d].", this.threadId, i));
+ returnValue.add (System.nanoTime() - start);
+ if (logger.isDebugEnabled())
+ {
+ logger.debug(String.format("Completed profiled run of testbody for thread [%1$d] count [%2$d].", this.threadId, i));
+ }
} catch (Exception e)
{
@@ -121,5 +137,6 @@
Assert.fail(e.getMessage(), e);
}
}
+ return returnValue ;
}
}
More information about the jboss-svn-commits
mailing list