You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/02/02 16:04:57 UTC

cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/test SingleThreadedPoolComparisonProfile.java

leif        02/02/02 07:04:57

  Added:       src/scratchpad/org/apache/avalon/excalibur/pool/test
                        SingleThreadedPoolComparisonProfile.java
  Log:
  New Pool Performance test
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/test/SingleThreadedPoolComparisonProfile.java
  
  Index: SingleThreadedPoolComparisonProfile.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.pool.test;
  
  import junit.framework.TestCase;
  
  import org.apache.avalon.excalibur.pool.HardResourceLimitingPool;
  import org.apache.avalon.excalibur.pool.ObjectFactory;
  import org.apache.avalon.excalibur.pool.Pool;
  import org.apache.avalon.excalibur.pool.Poolable;
  import org.apache.avalon.excalibur.pool.ResourceLimitingPool;
  import org.apache.avalon.excalibur.pool.SingleThreadedPool;
  import org.apache.avalon.excalibur.pool.SoftResourceLimitingPool;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.LogKitLogger;
  
  /**
   * This is used to profile and compare various pool implementations
   *  given a single access thread.
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   */
  public class SingleThreadedPoolComparisonProfile
      extends TestCase
  {
      /**
       * The TEST_SIZE defines the overall size of the tests.  Decreasing this will
       *  decrease the time the test takes to run, but also decrease its efficiency.
       */
      protected static final int TEST_SIZE = 50000;
  
      private Logger m_logger;
      private Logger m_poolLogger;
      
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      public SingleThreadedPoolComparisonProfile(String name)
      {
          super(name);
  
          // Set to debug to see more useful information.
          org.apache.log.Logger logger = 
              org.apache.log.Hierarchy.getDefaultHierarchy().getLoggerFor( "test" );
          logger.setPriority( org.apache.log.Priority.INFO );
          m_logger = new LogKitLogger( logger );
          
          // The output from the pools is too much data to be useful, so use a different logger.
          org.apache.log.Logger poolLogger =
              org.apache.log.Hierarchy.getDefaultHierarchy().getLoggerFor( "pool" );
          poolLogger.setPriority( org.apache.log.Priority.INFO );
          m_poolLogger = new LogKitLogger( poolLogger );
      }
      
      /*---------------------------------------------------------------
       * SingleThreadedPool vs ResourceLimitingPool TestCases
       *-------------------------------------------------------------*/
      /**
       * Compare the SingleThreadedPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SingleThreadedPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are small objects.
       */
      public void testCompare_SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets10_SmallPoolables()
          throws Exception
      {
          String name = "SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets10_SmallPoolables";
          
          Class         poolableClass = SmallPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SingleThreadedPool poolA = new SingleThreadedPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the SingleThreadedPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SingleThreadedPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 20 at a time,
       *  Poolables are small objects.
       */
      public void testCompare_SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets20_SmallPoolables()
          throws Exception
      {
          String name = "SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets20_SmallPoolables";
          
          Class         poolableClass = SmallPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SingleThreadedPool poolA = new SingleThreadedPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 20, poolableClass );
      }
  
      /**
       * Compare the SingleThreadedPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SingleThreadedPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are medium objects.
       */
      public void testCompare_SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets10_MediumPoolables()
          throws Exception
      {
          String name = "SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets10_MediumPoolables";
          
          Class         poolableClass = MediumPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SingleThreadedPool poolA = new SingleThreadedPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the SingleThreadedPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SingleThreadedPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 20 at a time,
       *  Poolables are medium objects.
       */
      public void testCompare_SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets20_MediumPoolables()
          throws Exception
      {
          String name = "SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets20_MediumPoolables";
          
          Class         poolableClass = MediumPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SingleThreadedPool poolA = new SingleThreadedPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 20, poolableClass );
      }
  
      /**
       * Compare the SingleThreadedPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SingleThreadedPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are large objects.
       */
      public void testCompare_SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets10_LargePoolables()
          throws Exception
      {
          String name = "SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets10_LargePoolables";
          
          Class         poolableClass = LargePoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SingleThreadedPool poolA = new SingleThreadedPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the SingleThreadedPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SingleThreadedPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 20 at a time,
       *  Poolables are large objects.
       */
      public void testCompare_SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets20_LargePoolables()
          throws Exception
      {
          String name = "SingleThreadedPool_And_ResourceLimitingPool_Max10_Gets20_LargePoolables";
          
          Class         poolableClass = LargePoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SingleThreadedPool poolA = new SingleThreadedPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 20, poolableClass );
      }
  
      /*---------------------------------------------------------------
       * SoftResourceLimitingPool vs ResourceLimitingPool TestCases
       *-------------------------------------------------------------*/
      /**
       * Compare the SoftResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SoftResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are small objects.
       */
      public void testCompare_SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_SmallPoolables()
          throws Exception
      {
          String name = "SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_SmallPoolables";
          
          Class         poolableClass = SmallPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SoftResourceLimitingPool poolA = new SoftResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the SoftResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SoftResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 20 at a time,
       *  Poolables are small objects.
       */
      public void testCompare_SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets20_SmallPoolables()
          throws Exception
      {
          String name = "SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets20_SmallPoolables";
          
          Class         poolableClass = SmallPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SoftResourceLimitingPool poolA = new SoftResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 20, poolableClass );
      }
  
      /**
       * Compare the SoftResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SoftResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are medium objects.
       */
      public void testCompare_SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_MediumPoolables()
          throws Exception
      {
          String name = "SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_MediumPoolables";
          
          Class         poolableClass = MediumPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SoftResourceLimitingPool poolA = new SoftResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the SoftResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SoftResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 20 at a time,
       *  Poolables are medium objects.
       */
      public void testCompare_SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets20_MediumPoolables()
          throws Exception
      {
          String name = "SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets20_MediumPoolables";
          
          Class         poolableClass = MediumPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SoftResourceLimitingPool poolA = new SoftResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 20, poolableClass );
      }
  
      /**
       * Compare the SoftResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SoftResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are large objects.
       */
      public void testCompare_SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_LargePoolables()
          throws Exception
      {
          String name = "SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_LargePoolables";
          
          Class         poolableClass = LargePoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SoftResourceLimitingPool poolA = new SoftResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the SoftResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a SoftResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 20 at a time,
       *  Poolables are large objects.
       */
      public void testCompare_SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets20_LargePoolables()
          throws Exception
      {
          String name = "SoftResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets20_LargePoolables";
          
          Class         poolableClass = LargePoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = false;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          SoftResourceLimitingPool poolA = new SoftResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 20, poolableClass );
      }
  
      /*---------------------------------------------------------------
       * HardResourceLimitingPool vs ResourceLimitingPool TestCases
       *-------------------------------------------------------------*/
      /**
       * Compare the HardResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a HardResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are small objects.
       */
      public void testCompare_HardResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_SmallPoolables()
          throws Exception
      {
          String name = "HardResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_SmallPoolables";
          
          Class         poolableClass = SmallPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = true;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          HardResourceLimitingPool poolA = new HardResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the HardResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a HardResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are medium objects.
       */
      public void testCompare_HardResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_MediumPoolables()
          throws Exception
      {
          String name = "HardResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_MediumPoolables";
          
          Class         poolableClass = MediumPoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = true;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          HardResourceLimitingPool poolA = new HardResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /**
       * Compare the HardResourceLimitingPool and ResourceLimitingPool when the
       *  ResourceLimitingPool is configured to act like a HardResourceLimitingPool.
       * <p>
       * Test will use pools with a max size of 10, while getting up to 10 at a time,
       *  Poolables are large objects.
       */
      public void testCompare_HardResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_LargePoolables()
          throws Exception
      {
          String name = "HardResourceLimitingPool_And_ResourceLimitingPool_Max10_Gets10_LargePoolables";
          
          Class         poolableClass = LargePoolable.class;
          ObjectFactory factory = new ClassInstanceObjectFactory( poolableClass, m_poolLogger );
          int           min          = 0;
          int           max          = 10;
          boolean       maxStrict    = true;
          boolean       blocking     = false;
          long          blockTimeout = 0;
          long          trimInterval = 0;
          
          HardResourceLimitingPool poolA = new HardResourceLimitingPool( factory, min, max );
          poolA.enableLogging( m_poolLogger );
          poolA.initialize();
          
          ResourceLimitingPool poolB = new ResourceLimitingPool( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
          poolB.enableLogging( m_poolLogger );
  
          generalTest( name, poolA, poolB, 10, poolableClass );
      }
  
      /*---------------------------------------------------------------
       * Test Classes
       *-------------------------------------------------------------*/
      public static class SmallPoolable
          implements Poolable
      {
          int a;
      }
  
      public static class MediumPoolable
          implements Poolable
      {
          int[] a = new int[100];
      }
  
      public static class LargePoolable
          implements Poolable
      {
          int[][] a = new int[100][50];
      }
      
      /*---------------------------------------------------------------
       * Utility Methods
       *-------------------------------------------------------------*/
      private void resetMemory()
      {
          System.gc();
          System.gc();
          
          // Let the system settle down.
          try
          {
              Thread.sleep( 50 );
          }
          catch (InterruptedException e ) {}
          Runtime runtime = Runtime.getRuntime();
          m_logger.debug( "Memory: " + ( runtime.totalMemory() - runtime.freeMemory() ) );
      }
      
      private String getShortClassName( Object o )
      {
          String name = o.getClass().getName();
          int pos = name.lastIndexOf('.');
          if ( pos > 0 )
          {
              name = name.substring( pos + 1 );
          }
          return name;
      }
      
      /**
       * The guts of the various test cases.  Will dispose the pools
       */
      private void generalTest(String name, Pool poolA, Pool poolB, int gets, Class poolableClass)
          throws Exception
      {
          m_logger.info( "Test Case: " + name );
          
          // Get the short class names
          final String poolAName = getShortClassName( poolA );
          final String poolBName = getShortClassName( poolB );
          
          // Start clean
          resetMemory();
          
          // Get a baseline speed for object creation
          final long noPoolStartTime = System.currentTimeMillis();
          for( int i = 0; i < TEST_SIZE; i++ )
          {
              final Poolable a1 = (Poolable)poolableClass.newInstance();
          }
          final long noPoolDuration = System.currentTimeMillis() - noPoolStartTime;
          m_logger.info( "     Unpooled time = " + noPoolDuration + "ms. to use " + TEST_SIZE + " objects." );
          resetMemory();
          
          
          // Get the time for poolA
          final long poolAStartTime = System.currentTimeMillis();
          final Poolable[] poolATmp = new Poolable[gets];
          final int poolALoops = TEST_SIZE / gets;
          for( int i = 0; i < poolALoops; i++ )
          {
              // Get some Poolables
              for ( int j = 0; j < gets; j++ )
              {
                  poolATmp[j] = poolA.get();
              }
              
              // Put the Poolables back
              for ( int j = 0; j < gets; j++ )
              {
                  poolA.put( poolATmp[j] );
                  poolATmp[j] = null;
              }
          }
          final long poolADuration = System.currentTimeMillis() - poolAStartTime;
          // Dispose if necessary
          if ( poolA instanceof Disposable ) {
              ((Disposable)poolA).dispose();
          }
          poolA = null;
          m_logger.info( "     " + poolAName + " time = " + poolADuration + "ms. to use " + TEST_SIZE + " objects, " + gets + " at a time." );
          resetMemory();
          
          
          // Get the time for poolB
          final long poolBStartTime = System.currentTimeMillis();
          final Poolable[] poolBTmp = new Poolable[gets];
          final int poolBLoops = TEST_SIZE / gets;
          for( int i = 0; i < poolBLoops; i++ )
          {
              // Get some Poolables
              for ( int j = 0; j < gets; j++ )
              {
                  poolBTmp[j] = poolB.get();
              }
              
              // Put the Poolables back
              for ( int j = 0; j < gets; j++ )
              {
                  poolB.put( poolBTmp[j] );
                  poolBTmp[j] = null;
              }
          }
          final long poolBDuration = System.currentTimeMillis() - poolBStartTime;
          // Dispose if necessary
          if ( poolB instanceof Disposable ) {
              ((Disposable)poolB).dispose();
          }
          poolB = null;
          m_logger.info( "     " + poolBName + " time = " + poolBDuration + "ms. to use " + TEST_SIZE + " objects, " + gets + " at a time." );
          resetMemory();
          
          // Show a summary
          if ( m_logger.isInfoEnabled() )
          {
              double mult;
              mult = ( poolADuration > 0 ? ( noPoolDuration * 100 / poolADuration ) / 100.0 : Float.POSITIVE_INFINITY );
              m_logger.info( "  => " + poolAName + " is " + mult + " X as fast as not pooling." );
              
              mult = ( poolBDuration > 0 ? ( noPoolDuration * 100 / poolBDuration ) / 100.0 : Float.POSITIVE_INFINITY );
              m_logger.info( "  => " + poolBName + " is " + mult + " X as fast as not pooling." );
              
              mult = ( poolBDuration > 0 ? ( poolADuration * 100 / poolBDuration ) / 100.0 : Float.POSITIVE_INFINITY );
              m_logger.info( "  => " + poolBName + " is " + mult + " X as fast as " + poolAName + "." );
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>