001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package test.performance.standard;
023:
024: import junit.framework.TestCase;
025: import test.performance.PerformanceSUITE;
026: import test.performance.standard.support.Standard;
027:
028: import javax.management.*;
029:
030: import org.jboss.mx.server.ServerConstants;
031:
032: public class OptimizedThroughputTEST extends TestCase implements
033: ServerConstants {
034:
035: public OptimizedThroughputTEST(String s) {
036: super (s);
037: }
038:
039: public void testThroughput() throws Exception {
040:
041: class MyThread implements Runnable {
042:
043: private boolean keepRunning = true;
044:
045: public void run() {
046: try {
047: Thread.sleep(PerformanceSUITE.THROUGHPUT_TIME);
048: } catch (InterruptedException e) {
049:
050: }
051:
052: keepRunning = false;
053: }
054:
055: public boolean isKeepRunning() {
056: return keepRunning;
057: }
058: }
059:
060: MyThread myThread = new MyThread();
061: Thread t = new Thread(myThread);
062: Standard std = new Standard();
063:
064: String method = "mixedArguments";
065: String[] signature = new String[] { Integer.class.getName(),
066: int.class.getName(), Object[][][].class.getName(),
067: Attribute.class.getName() };
068:
069: Object[] args = new Object[] {
070: new Integer(1234),
071: new Integer(455617),
072: new Object[][][] {
073: { { "1x1x1", "1x1x2", "1x1x3" },
074: { "1x2x1", "1x2x2", "1x2x3" },
075: { "1x3x1", "1x3x2", "1x3x3" } },
076:
077: { { "2x1x1", "2x1x2", "2x1x3" },
078: { "2x2x1", "2x2x2", "2x2x3" },
079: { "2x3x1", "2x3x2", "2x3x3" } },
080:
081: { { "3x1x1", "3x1x2", "3x1x3" },
082: { "3x2x1", "3x2x2", "3x2x3" },
083: { "3x3x1", "3x3x2", "3x3x3" } } },
084: new Attribute("attribute", "value") };
085:
086: System.setProperty(OPTIMIZE_REFLECTED_DISPATCHER, "true");
087:
088: try {
089: MBeanServer server = MBeanServerFactory.createMBeanServer();
090: ObjectName name = new ObjectName("test:test=test");
091:
092: server.registerMBean(std, name);
093:
094: t.start();
095: while (myThread.isKeepRunning()) {
096: server.invoke(name, method, args, signature);
097: }
098:
099: System.out
100: .println("\nStandard MBean Throughput (OPTIMIZED): "
101: + std.getCount()
102: / (PerformanceSUITE.THROUGHPUT_TIME / PerformanceSUITE.SECOND)
103: + " invocations per second.");
104: System.out.println("(Total: " + std.getCount() + ")\n");
105: } finally {
106: System.setProperty(OPTIMIZE_REFLECTED_DISPATCHER, "false");
107: }
108: }
109:
110: }
|