1 22 package org.jboss.ejb3.test.microbench.unit; 23 24 import junit.framework.Test; 25 import org.jboss.ejb3.test.microbench.StatelessHomeRemote; 26 import org.jboss.ejb3.test.microbench.StatelessRemote; 27 import org.jboss.ejb3.test.microbench.StatelessRemote21; 28 import org.jboss.jmx.adaptor.rmi.RMIAdaptor; 29 import org.jboss.test.JBossTestCase; 30 31 import javax.management.MBeanServerConnection ; 32 import javax.management.ObjectName ; 33 34 40 41 public class BenchUnitTestCase 42 extends JBossTestCase 43 { 44 public BenchUnitTestCase(String name) 45 { 46 47 super(name); 48 49 } 50 51 public void testLocalBenchmark() throws Exception 52 { 53 MBeanServerConnection server = getServer(); 54 ObjectName testerName = new ObjectName ("jboss.ejb3:service=Benchmark"); 55 Object [] params = {new Integer (100000)}; 56 String [] sig = {"int"}; 57 System.out.println("21Local: " + server.invoke(testerName, "benchLocalStateless21", params, sig)); 58 System.out.println("30Local: " + server.invoke(testerName, "benchLocalStateless30", params, sig)); 59 60 61 } 62 63 public void testRemoteBenchmark() throws Exception 64 { 65 StatelessRemote remote = (StatelessRemote) getInitialContext().lookup("StatelessBean/remote"); 66 StatelessHomeRemote home = (StatelessHomeRemote) getInitialContext().lookup("StatelessBean21Remote"); 67 StatelessRemote21 remote21 = home.create(); 68 69 long start = System.currentTimeMillis(); 70 for (int i = 0; i < 1000; i++) 71 { 72 remote21.test(i); 73 } 74 long end = System.currentTimeMillis() - start; 75 System.out.println("21Remote: " + end); 76 77 start = System.currentTimeMillis(); 78 for (int i = 0; i < 1000; i++) 79 { 80 remote.test(i); 81 } 82 end = System.currentTimeMillis() - start; 83 System.out.println("30Remote: " + end); 84 85 } 86 87 public static Test suite() throws Exception 88 { 89 return getDeploySetup(BenchUnitTestCase.class, "benchmark-ejb3-test.sar"); 90 } 91 92 } 93 | Popular Tags |