01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
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: public StandardMBeanThroughputTEST(String s) {
33: super (s);
34: }
35:
36: public void testThroughput() throws Exception {
37: MyThread myThread = new MyThread();
38: Thread t = new Thread(myThread);
39: StandardMBeanExtension std = new StandardMBeanExtension();
40:
41: String method = "mixedArguments";
42: String[] signature = new String[] { Integer.class.getName(),
43: Integer.TYPE.getName(), Object[][][].class.getName(),
44: Attribute.class.getName() };
45:
46: Object[] args = new Object[] {
47: new Integer(1234),
48: new Integer(5678),
49: new Object[][][] {
50: { { "1x1x1", "1x1x2", "1x1x3" },
51: { "1x2x1", "1x2x2", "1x2x3" },
52: { "1x3x1", "1x3x2", "1x3x3" } },
53:
54: { { "2x1x1", "2x1x2", "2x1x3" },
55: { "2x2x1", "2x2x2", "2x2x3" },
56: { "2x3x1", "2x3x2", "2x3x3" } },
57:
58: { { "3x1x1", "3x1x2", "3x1x3" },
59: { "3x2x1", "3x2x2", "3x2x3" },
60: { "3x3x1", "3x3x2", "3x3x3" } } },
61: new Attribute("attribute", "value") };
62:
63: MBeanServer server = MBeanServerFactory.createMBeanServer();
64: ObjectName name = new ObjectName("test:test=test");
65:
66: server.registerMBean(std, name);
67:
68: t.start();
69: while (myThread.isKeepRunning()) {
70: server.invoke(name, method, args, signature);
71: }
72:
73: System.out
74: .println("\nStandardMBeanExtension Throughput: "
75: + std.getCount()
76: / (PerformanceSUITE.THROUGHPUT_TIME / PerformanceSUITE.SECOND)
77: + " invocations per second.");
78: System.out.println("(Total: " + std.getCount() + ")\n");
79: }
80:
81: class MyThread implements Runnable {
82:
83: private boolean keepRunning = true;
84:
85: public void run() {
86: try {
87: Thread.sleep(PerformanceSUITE.THROUGHPUT_TIME);
88: } catch (InterruptedException e) {
89:
90: }
91:
92: keepRunning = false;
93: }
94:
95: public boolean isKeepRunning() {
96: return keepRunning;
97: }
98: }
99: }
|