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