User: starksm
Date: 02/02/16 13:14:56
Added: src/main/org/jboss/test/perf/test PerfUnitTestCase.java
Log:
Add standard unit test of in-VM remote vs local interface overhead
Revision Changes Path
1.1
jbosstest/src/main/org/jboss/test/perf/test/PerfUnitTestCase.java
Index: PerfUnitTestCase.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.test.perf.test;
import java.io.IOException;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jboss.test.perf.interfaces.PerfTestSession;
import org.jboss.test.perf.interfaces.PerfTestSessionHome;
import org.jboss.test.perf.interfaces.Probe;
import org.jboss.test.perf.interfaces.ProbeHome;
import org.jboss.test.JBossTestCase;
/** Tests of the Probe session bean method call overhead inside
of the JBoss VM. This is performed using the PerfTestSession
wrapper.
@author [EMAIL PROTECTED]
@version $Revision: 1.1 $
*/
public class PerfUnitTestCase extends JBossTestCase
{
int iterationCount;
public PerfUnitTestCase(String name)
{
super(name);
iterationCount = getIterationCount();
}
public void testInVMCalls() throws Exception
{
getLog().debug("+++ testInVMCalls()");
Object obj = getInitialContext().lookup("PerfTestSession");
obj = PortableRemoteObject.narrow(obj, PerfTestSessionHome.class);
PerfTestSessionHome home = (PerfTestSessionHome) obj;
getLog().debug("Found PerfTestSessionHome @ jndiName=PerfTestSessionHome");
PerfTestSession bean = home.create();
getLog().debug("Created PerfTestSession");
long start = System.currentTimeMillis();
String report = bean.runProbeTests(iterationCount);
long end = System.currentTimeMillis();
long elapsed = end - start;
getLog().debug("Elapsed time = "+(elapsed / iterationCount));
getLog().info("The testInVMCalls report is:\n"+report);
}
public void testInVMLocalCalls() throws Exception
{
getLog().debug("+++ testInVMLocalCalls()");
Object obj = getInitialContext().lookup("PerfTestSession");
obj = PortableRemoteObject.narrow(obj, PerfTestSessionHome.class);
PerfTestSessionHome home = (PerfTestSessionHome) obj;
getLog().debug("Found PerfTestSessionHome @ jndiName=PerfTestSessionHome");
PerfTestSession bean = home.create();
getLog().debug("Created PerfTestSession");
long start = System.currentTimeMillis();
String report = bean.runProbeLocalTests(iterationCount);
long end = System.currentTimeMillis();
long elapsed = end - start;
getLog().debug("Elapsed time = "+(elapsed / iterationCount));
getLog().info("The testInVMLocalCalls report is:\n"+report);
}
public static Test suite() throws Exception
{
Test test = getDeploySetup(PerfUnitTestCase.class, "perf.jar");
return test;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development