1 22 package test.performance.standard; 23 24 import junit.framework.TestCase; 25 import test.performance.PerformanceSUITE; 26 import test.performance.standard.support.Standard; 27 28 import javax.management.*; 29 30 import org.jboss.mx.server.ServerConstants; 31 32 33 public class OptimizedThroughputTEST extends TestCase 34 implements ServerConstants 35 { 36 37 public OptimizedThroughputTEST(String s) 38 { 39 super(s); 40 } 41 42 public void testThroughput() throws Exception 43 { 44 45 class MyThread implements Runnable 46 { 47 48 private boolean keepRunning = true; 49 50 public void run() 51 { 52 try 53 { 54 Thread.sleep(PerformanceSUITE.THROUGHPUT_TIME); 55 } 56 catch (InterruptedException e) 57 { 58 59 } 60 61 keepRunning = false; 62 } 63 64 public boolean isKeepRunning() 65 { 66 return keepRunning; 67 } 68 } 69 70 MyThread myThread = new MyThread(); 71 Thread t = new Thread (myThread); 72 Standard std = new Standard(); 73 74 String method = "mixedArguments"; 75 String [] signature = new String [] { 76 Integer .class.getName(), 77 int.class.getName(), 78 Object [][][].class.getName(), 79 Attribute.class.getName() 80 }; 81 82 Object [] args = new Object [] { 83 new Integer (1234), 84 new Integer (455617), 85 new Object [][][] { 86 { 87 { "1x1x1", "1x1x2", "1x1x3" }, 88 { "1x2x1", "1x2x2", "1x2x3" }, 89 { "1x3x1", "1x3x2", "1x3x3" } 90 }, 91 92 { 93 { "2x1x1", "2x1x2", "2x1x3" }, 94 { "2x2x1", "2x2x2", "2x2x3" }, 95 { "2x3x1", "2x3x2", "2x3x3" } 96 }, 97 98 { 99 { "3x1x1", "3x1x2", "3x1x3" }, 100 { "3x2x1", "3x2x2", "3x2x3" }, 101 { "3x3x1", "3x3x2", "3x3x3" } 102 } 103 }, 104 new Attribute("attribute", "value") 105 }; 106 107 System.setProperty(OPTIMIZE_REFLECTED_DISPATCHER, "true"); 108 109 try 110 { 111 MBeanServer server = MBeanServerFactory.createMBeanServer(); 112 ObjectName name = new ObjectName("test:test=test"); 113 114 server.registerMBean(std, name); 115 116 t.start(); 117 while(myThread.isKeepRunning()) 118 { 119 server.invoke(name, method, args, signature); 120 } 121 122 System.out.println("\nStandard MBean Throughput (OPTIMIZED): " + 123 std.getCount() / (PerformanceSUITE.THROUGHPUT_TIME / PerformanceSUITE.SECOND) + 124 " invocations per second."); 125 System.out.println("(Total: " + std.getCount() + ")\n"); 126 } 127 finally 128 { 129 System.setProperty(OPTIMIZE_REFLECTED_DISPATCHER, "false"); 130 } 131 } 132 133 134 } 135 | Popular Tags |