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