Examples of FastClass


Examples of net.sf.cglib.reflect.FastClass

//    }

    private void doNothingTimings() throws Exception {
        Method myMethod = MockGBean.class.getMethod("doNothing", (Class[])null);

        FastClass myFastClass = FastClass.create(MockGBean.class);
        int myMethodIndex = myFastClass.getIndex("doNothing", new Class[0]);

        MockGBean instance = new MockGBean("foo", 12);

        // normal invoke
        int iterations = 100000000;
        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++) {
            instance.doNothing();
        }
        long end = System.currentTimeMillis();
        printResults("Normal", end, start, iterations);

        // reflection
        iterations = 1000000;
        for (int i = 0; i < iterations; i++) {
            myMethod.invoke(instance, (Class[])null);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            myMethod.invoke(instance, (Class[])null);
        }
        end = System.currentTimeMillis();
        printResults("Reflection", end, start, iterations);

        // fast class
        iterations = 5000000;
        for (int i = 0; i < iterations; i++) {
            myFastClass.invoke(myMethodIndex, instance, null);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            myFastClass.invoke(myMethodIndex, instance, null);
        }
        end = System.currentTimeMillis();
        printResults("FastClass", end, start, iterations);

        // start a kernel
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

    }

    public void echoTimings() throws Exception {
        Method myMethod = MockGBean.class.getMethod("echo", new Class[]{String.class});

        FastClass myFastClass = FastClass.create(MockGBean.class);
        int myMethodIndex = myFastClass.getIndex("echo", new Class[]{String.class});
        String msg = "Some message";
        Object[] args = new Object[]{msg};
        String result;

        MockGBean instance = new MockGBean("foo", 12);


        // normal invoke
        int iterations = 100000000;
        for (int i = 0; i < iterations; i++) {
            result = instance.echo(msg);
        }
        long start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            result = instance.echo(msg);
        }
        long end = System.currentTimeMillis();
        printResults("Normal", end, start, iterations);

        // reflection
        iterations = 10000000;
        for (int i = 0; i < iterations; i++) {
            result = (String) myMethod.invoke(instance, args);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            result = (String) myMethod.invoke(instance, args);
        }
        end = System.currentTimeMillis();
        printResults("Reflection", end, start, iterations);

        // fast class
        iterations = 10000000;
        for (int i = 0; i < iterations; i++) {
            result = (String) myFastClass.invoke(myMethodIndex, instance, args);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            result = (String) myFastClass.invoke(myMethodIndex, instance, args);
        }
        end = System.currentTimeMillis();
        printResults("FastClass", end, start, iterations);

        // start a kernel
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

    }

    private static void doNothingTimings() throws Exception {
        Method myMethod = MockGBean.class.getMethod("doNothing", null);

        FastClass myFastClass = FastClass.create(MockGBean.class);
        int myMethodIndex = myFastClass.getIndex("doNothing", new Class[0]);

        MockGBean instance = new MockGBean("foo", 12);

        // normal invoke
        int iterations = 100000000;
        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++) {
            instance.doNothing();
        }
        long end = System.currentTimeMillis();
        printResults("Normal", end, start, iterations);

        // reflection
        iterations = 1000000;
        for (int i = 0; i < iterations; i++) {
            myMethod.invoke(instance, null);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            myMethod.invoke(instance, null);
        }
        end = System.currentTimeMillis();
        printResults("Reflection", end, start, iterations);

        // fast class
        iterations = 5000000;
        for (int i = 0; i < iterations; i++) {
            myFastClass.invoke(myMethodIndex, instance, null);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            myFastClass.invoke(myMethodIndex, instance, null);
        }
        end = System.currentTimeMillis();
        printResults("FastClass", end, start, iterations);

        // start a kernel
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass


    private static void echoTimings() throws Exception {
        Method myMethod = MockGBean.class.getMethod("echo", new Class[]{String.class});

        FastClass myFastClass = FastClass.create(MockGBean.class);
        int myMethodIndex = myFastClass.getIndex("echo", new Class[]{String.class});
        String msg = "Some message";
        Object[] args = new Object[]{msg};
        String result;

        MockGBean instance = new MockGBean("foo", 12);


        // normal invoke
        int iterations = 100000000;
        for (int i = 0; i < iterations; i++) {
            result = instance.echo(msg);
        }
        long start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            result = instance.echo(msg);
        }
        long end = System.currentTimeMillis();
        printResults("Normal", end, start, iterations);

        // reflection
        iterations = 10000000;
        for (int i = 0; i < iterations; i++) {
            result = (String) myMethod.invoke(instance, args);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            result = (String) myMethod.invoke(instance, args);
        }
        end = System.currentTimeMillis();
        printResults("Reflection", end, start, iterations);

        // fast class
        iterations = 10000000;
        for (int i = 0; i < iterations; i++) {
            result = (String) myFastClass.invoke(myMethodIndex, instance, args);
        }
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            result = (String) myFastClass.invoke(myMethodIndex, instance, args);
        }
        end = System.currentTimeMillis();
        printResults("FastClass", end, start, iterations);

        // start a kernel
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

        return gbeanInvoker.invoke(objectName, args);
    }

    private ProxyInvoker[] createGBeanInvokers(Kernel kernel) {
        // build the method lookup table
        FastClass fastClass = FastClass.create(proxyType);
        ProxyInvoker[] invokers = new ProxyInvoker[fastClass.getMaxIndex() + 1];
        Method[] methods = proxyType.getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            int interfaceIndex = getSuperIndex(proxyType, method);
            if (interfaceIndex >= 0) {
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

  public ReflectionOptimizer getReflectionOptimizer(
      Class clazz,
          String[] getterNames,
          String[] setterNames,
          Class[] types) {
    FastClass fastClass;
    BulkBean bulkBean;
    try {
      fastClass = FastClass.create( clazz );
      bulkBean = BulkBean.create( clazz, getterNames, setterNames, types );
      if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
        if ( fastClass == null ) {
          bulkBean = null;
        }
        else {
          //test out the optimizer:
          Object instance = fastClass.newInstance();
          bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) );
        }
      }
    }
    catch( Throwable t ) {
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

  public ReflectionOptimizer getReflectionOptimizer(
      Class clazz,
          String[] getterNames,
          String[] setterNames,
          Class[] types) {
    FastClass fastClass;
    BulkBean bulkBean;
    try {
      fastClass = FastClass.create( clazz );
      bulkBean = BulkBean.create( clazz, getterNames, setterNames, types );
      if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
        if ( fastClass == null ) {
          bulkBean = null;
        }
        else {
          //test out the optimizer:
          Object instance = fastClass.newInstance();
          bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) );
        }
      }
    }
    catch( Throwable t ) {
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

    private ProxyInvoker[] createRawGBeanInvokers(RawInvoker rawInvoker, Class proxyType) {
        Map operations = rawInvoker.getOperationIndex();
        Map attributes = rawInvoker.getAttributeIndex();

        // build the method lookup table
        FastClass fastClass = FastClass.create(proxyType);
        ProxyInvoker[] invokers = new ProxyInvoker[fastClass.getMaxIndex() + 1];
        Method[] methods = proxyType.getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            int interfaceIndex = getSuperIndex(proxyType, method);
            if (interfaceIndex >= 0) {
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

            GOperationInfo operationInfo = (GOperationInfo) iterator.next();
            operationSignatures.add(new GOperationSignature(operationInfo.getName(), operationInfo.getParameterList()));
        }

        // build the method lookup table
        FastClass fastClass = FastClass.create(proxyType);
        ProxyInvoker[] invokers = new ProxyInvoker[fastClass.getMaxIndex() + 1];
        Method[] methods = proxyType.getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            int interfaceIndex = getSuperIndex(proxyType, method);
            if (interfaceIndex >= 0) {
View Full Code Here

Examples of net.sf.cglib.reflect.FastClass

      this.injectionPoint = injectionPoint;
      this.constructor = (Constructor<T>) injectionPoint.getMember();
      this.callbacks = callbacks;
      this.methodInterceptors = methodInterceptors;

      FastClass fastClass = newFastClass(enhanced, BytecodeGen.Visibility.forMember(constructor));
      this.fastConstructor = fastClass.getConstructor(constructor.getParameterTypes());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.