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: public class ThroughputTEST extends TestCase {
031:
032: public ThroughputTEST(String s) {
033: super (s);
034: }
035:
036: public void testThroughput() throws Exception {
037:
038: MyThread myThread = new MyThread();
039: Thread t = new Thread(myThread);
040: Standard std = new Standard();
041:
042: String method = "mixedArguments";
043: String[] signature = new String[] { Integer.class.getName(),
044: int.class.getName(), Object[][][].class.getName(),
045: Attribute.class.getName() };
046:
047: Object[] args = new Object[] {
048: new Integer(1234),
049: new Integer(455617),
050: new Object[][][] {
051: { { "1x1x1", "1x1x2", "1x1x3" },
052: { "1x2x1", "1x2x2", "1x2x3" },
053: { "1x3x1", "1x3x2", "1x3x3" } },
054:
055: { { "2x1x1", "2x1x2", "2x1x3" },
056: { "2x2x1", "2x2x2", "2x2x3" },
057: { "2x3x1", "2x3x2", "2x3x3" } },
058:
059: { { "3x1x1", "3x1x2", "3x1x3" },
060: { "3x2x1", "3x2x2", "3x2x3" },
061: { "3x3x1", "3x3x2", "3x3x3" } } },
062: new Attribute("attribute", "value") };
063:
064: MBeanServer server = MBeanServerFactory.createMBeanServer();
065: ObjectName name = new ObjectName("test:test=test");
066:
067: server.registerMBean(std, name);
068:
069: t.start();
070: while (myThread.isKeepRunning()) {
071: server.invoke(name, method, args, signature);
072: }
073:
074: System.out
075: .println("\nStandard MBean Throughput: "
076: + std.getCount()
077: / (PerformanceSUITE.THROUGHPUT_TIME / PerformanceSUITE.SECOND)
078: + " invocations per second.");
079: System.out.println("(Total: " + std.getCount() + ")\n");
080: }
081:
082: class MyThread implements Runnable {
083:
084: private boolean keepRunning = true;
085:
086: public void run() {
087: try {
088: Thread.sleep(PerformanceSUITE.THROUGHPUT_TIME);
089: } catch (InterruptedException e) {
090:
091: }
092:
093: keepRunning = false;
094: }
095:
096: public boolean isKeepRunning() {
097: return keepRunning;
098: }
099: }
100:
101: }
|