geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject cvs commit: incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/gbean Speed.java
Date Wed, 02 Jun 2004 20:40:58 GMT
jboynes     2004/06/02 13:40:58

  Modified:    modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        CGLibMethodInterceptor.java
               modules/kernel/src/test/org/apache/geronimo/gbean Speed.java
  Added:       modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        RawGetAttributeInvoker.java
                        RawOperationInvoker.java
                        RawSetAttributeInvoker.java
  Removed:     modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        RawGBeanInvoker.java
  Log:
  Removed case statement
  Made RawInvokers final
  Little bit faster
  
  Revision  Changes    Path
  1.2       +6 -6      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibMethodInterceptor.java
  
  Index: CGLibMethodInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibMethodInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CGLibMethodInterceptor.java	2 Jun 2004 06:49:23 -0000	1.1
  +++ CGLibMethodInterceptor.java	2 Jun 2004 20:40:58 -0000	1.2
  @@ -92,7 +92,7 @@
           this.stopped = true;
       }
   
  -    public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy)
throws Throwable {
  +    public final Object intercept(final Object object, final Method method, final Object[]
args, final MethodProxy proxy) throws Throwable {
           GBeanInvoker gbeanInvoker;
   
           int interfaceIndex = proxy.getSuperIndex();
  @@ -154,27 +154,27 @@
       private GBeanInvoker createRawGBeanInvoker(RawInvoker rawInvoker, Method method, Map
operations, Map attributes) {
           if (operations.containsKey(new GOperationSignature(method))) {
               int methodIndex = ((Integer) operations.get(new GOperationSignature(method))).intValue();
  -            return new RawGBeanInvoker(rawInvoker, methodIndex, GBeanInvoker.OPERATION);
  +            return new RawOperationInvoker(rawInvoker, methodIndex);
           }
   
           if (method.getName().startsWith("get")) {
               Integer methodIndex = ((Integer) attributes.get(method.getName().substring(3)));
               if (methodIndex != null) {
  -                return new RawGBeanInvoker(rawInvoker, methodIndex.intValue(), GBeanInvoker.GETTER);
  +                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
               }
           }
   
           if (method.getName().startsWith("is")) {
               Integer methodIndex = ((Integer) attributes.get(method.getName().substring(2)));
               if (methodIndex != null) {
  -                return new RawGBeanInvoker(rawInvoker, methodIndex.intValue(), GBeanInvoker.GETTER);
  +                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
               }
           }
   
           if (method.getName().startsWith("set")) {
               Integer methodIndex = ((Integer) attributes.get(method.getName().substring(3)));
               if (methodIndex != null) {
  -                return new RawGBeanInvoker(rawInvoker, methodIndex.intValue(), GBeanInvoker.SETTER);
  +                return new RawSetAttributeInvoker(rawInvoker, methodIndex.intValue());
               }
           }
           return null;
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawGetAttributeInvoker.java
  
  Index: RawGetAttributeInvoker.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.geronimo.gbean.jmx;
  
  import javax.management.ObjectName;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/06/02 20:40:58 $
   */
  public final class RawGetAttributeInvoker implements GBeanInvoker {
      private final RawInvoker rawInvoker;
      private final int methodIndex;
  
      public RawGetAttributeInvoker(RawInvoker rawInvoker, int methodIndex) {
          this.rawInvoker = rawInvoker;
          this.methodIndex = methodIndex;
      }
  
      public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable
{
          return rawInvoker.getAttribute(methodIndex);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawOperationInvoker.java
  
  Index: RawOperationInvoker.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.geronimo.gbean.jmx;
  
  import javax.management.ObjectName;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/06/02 20:40:58 $
   */
  public final class RawOperationInvoker implements GBeanInvoker {
      private final RawInvoker rawInvoker;
      private final int methodIndex;
  
      public RawOperationInvoker(RawInvoker rawInvoker, int methodIndex) {
          this.rawInvoker = rawInvoker;
          this.methodIndex = methodIndex;
      }
  
      public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable
{
          return rawInvoker.invoke(methodIndex, arguments);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawSetAttributeInvoker.java
  
  Index: RawSetAttributeInvoker.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.geronimo.gbean.jmx;
  
  import javax.management.ObjectName;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/06/02 20:40:58 $
   */
  public final class RawSetAttributeInvoker implements GBeanInvoker {
      private final RawInvoker rawInvoker;
      private final int methodIndex;
  
      public RawSetAttributeInvoker(RawInvoker rawInvoker, int methodIndex) {
          this.rawInvoker = rawInvoker;
          this.methodIndex = methodIndex;
      }
  
      public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable
{
          rawInvoker.setAttribute(methodIndex, arguments[0]);
          return null;
      }
  }
  
  
  
  1.2       +14 -9     incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
  
  Index: Speed.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Speed.java	2 Jun 2004 20:10:08 -0000	1.1
  +++ Speed.java	2 Jun 2004 20:40:58 -0000	1.2
  @@ -64,8 +64,11 @@
   
           // normal invoke
           int iterations = 100000000;
  -        for (int i = 0; i < iterations; i++) {
  -            instance.doNothing();
  +        String msg = "hhhh";
  +        for (int j=0 ; j < 10; j++) {
  +            for (int i = 0; i < iterations; i++) {
  +                msg= instance.echo(msg);
  +            }
           }
           long start = System.currentTimeMillis();
           for (int i = 0; i < iterations; i++) {
  @@ -75,7 +78,7 @@
           printResults("Normal", end, start, iterations);
   
           // reflection
  -        iterations = 1000000;
  +        iterations = 100000000;
           for (int i = 0; i < iterations; i++) {
               myMethod.invoke(instance, null);
           }
  @@ -87,7 +90,7 @@
           printResults("Reflection", end, start, iterations);
   
           // fast class
  -        iterations = 10000000;
  +        iterations = 50000000;
           for (int i = 0; i < iterations; i++) {
               myFastClass.invoke(myMethodIndex, instance, null);
           }
  @@ -113,7 +116,7 @@
           ProxyMethodInterceptor vmMethodInterceptor = vmProxyFactory.getMethodInterceptor();
           MyInterface vmProxy = (MyInterface) vmProxyFactory.create(vmMethodInterceptor);
           vmMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
  -        iterations = 50000;
  +        iterations = 1000000;
           for (int i = 0; i < iterations; i++) {
               vmProxy.doNothing();
           }
  @@ -125,6 +128,7 @@
           printResults("ReflectionProxy", end, start, iterations);
   
           // cglib proxy (front half)
  +/*
           ProxyFactory frontCGLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
           ProxyMethodInterceptor frontCGLibMethodInterceptor = new CGLibMethodInterceptor(MyInterface.class);
           Class enhancedType = frontCGLibProxyFactory.create(frontCGLibMethodInterceptor).getClass();
  @@ -135,7 +139,7 @@
           };
           MyInterface frontCGLibProxy = (MyInterface) frontCGLibProxyFactory.create(frontCGLibMethodInterceptor);
           frontCGLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
  -        iterations = 10000000;
  +        iterations = 100000000;
           for (int i = 0; i < iterations; i++) {
               frontCGLibProxy.doNothing();
           }
  @@ -145,6 +149,7 @@
           }
           end = System.currentTimeMillis();
           printResults("Front CGLibProxy", end, start, iterations);
  +*/
   
           // Raw Invoker
           RawInvoker rawInvoker = (RawInvoker) kernel.getAttribute(objectName, "$$RAW_INVOKER$$");
  @@ -165,7 +170,7 @@
           ProxyMethodInterceptor cgLibMethodInterceptor = cgLibProxyFactory.getMethodInterceptor();
           MyInterface cgLibProxy = (MyInterface) cgLibProxyFactory.create(cgLibMethodInterceptor);
           cgLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
  -        iterations = 1000000;
  +        iterations = 10000000;
           for (int i = 0; i < iterations; i++) {
               cgLibProxy.doNothing();
           }
  
  
  

Mime
View raw message