[jboss-cvs] JBossCache/tests/perf/org/jboss/cache/loader ...

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:31:01 EDT 2006


  User: msurtani
  Date: 06/09/06 11:31:01

  Modified:    tests/perf/org/jboss/cache/loader   CacheLoaderPerfTest.java
                        JDBCCacheLoaderPerfTest.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.8       +214 -214  JBossCache/tests/perf/org/jboss/cache/loader/CacheLoaderPerfTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderPerfTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/loader/CacheLoaderPerfTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- CacheLoaderPerfTest.java	20 Jul 2006 08:53:08 -0000	1.7
  +++ CacheLoaderPerfTest.java	6 Sep 2006 15:31:01 -0000	1.8
  @@ -38,7 +38,7 @@
           cache.getConfiguration().setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + tmpLocation, false, false, false));
           File dir = new File(tmpLocation);
           if (!dir.exists()) dir.mkdirs();
  -        cache.startService();
  +      cache.start();
       }
   
       protected void tearDown() throws Exception
  @@ -46,7 +46,7 @@
           if (cache != null)
           {
               cache.remove("/");
  -            cache.stopService();
  +         cache.stop();
               cache = null;
               totalTime = 0;
   
  @@ -60,7 +60,7 @@
       {
           Thread threads[] = new Thread[NUM_THREADS];
   
  -        for (int i=0; i<NUM_THREADS; i++)
  +      for (int i = 0; i < NUM_THREADS; i++)
           {
               threads[i] = new Thread()
               {
  @@ -70,9 +70,9 @@
                   {
                       Fqn base = new Fqn(new Object[]{"Threads", getName()});
                       long start = System.currentTimeMillis();
  -                    for (int j=0; j<NUM_TIMES_PER_THREAD; j++)
  +                  for (int j = 0; j < NUM_TIMES_PER_THREAD; j++)
                       {
  -                        cache.put(base, "key"+j, "value"+j);
  +                     cache.put(base, "key" + j, "value" + j);
                       }
                       long timeTaken = System.currentTimeMillis() - start;
                       totalTime += timeTaken;
  @@ -152,7 +152,7 @@
                           long start = System.currentTimeMillis();
                           for (int j = 0; j < NUM_TIMES_PER_THREAD; j++)
                           {
  -                            cache.get(fqn, "key"+j);
  +                     cache.get(fqn, "key" + j);
                               cache.evict(fqn);
                           }
                           long timeTaken = System.currentTimeMillis() - start;
  @@ -233,7 +233,7 @@
           System.out.println("  NumLoopsPerThread: " + NUM_TIMES_PER_THREAD);
           System.out.println("  Total time:        " + totalTime);
           System.out.println("  Avg time:          " + (totalTime / (NUM_TIMES_PER_THREAD * NUM_THREADS)));
  -        System.out.println("  Avg time for 1k:   " + ((1000*totalTime) / (NUM_TIMES_PER_THREAD * NUM_THREADS)));
  +      System.out.println("  Avg time for 1k:   " + ((1000 * totalTime) / (NUM_TIMES_PER_THREAD * NUM_THREADS)));
           System.out.println("------------------------------------");
       }
   
  
  
  
  1.4       +248 -243  JBossCache/tests/perf/org/jboss/cache/loader/JDBCCacheLoaderPerfTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JDBCCacheLoaderPerfTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/loader/JDBCCacheLoaderPerfTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- JDBCCacheLoaderPerfTest.java	20 Jul 2006 08:05:18 -0000	1.3
  +++ JDBCCacheLoaderPerfTest.java	6 Sep 2006 15:31:01 -0000	1.4
  @@ -32,9 +32,9 @@
       private static final int NUM_THREADS = 10;
       private static final String threadNamePrefix = "TesterThread-";
       
  -    private long[] putStat = new long[NUM_THREADS*NUM_TIMES_PER_THREAD];
  -    private long[] getStat = new long[NUM_THREADS*NUM_TIMES_PER_THREAD];
  -    private long[] removeStat = new long[NUM_THREADS*NUM_TIMES_PER_THREAD];
  +   private long[] putStat = new long[NUM_THREADS * NUM_TIMES_PER_THREAD];
  +   private long[] getStat = new long[NUM_THREADS * NUM_TIMES_PER_THREAD];
  +   private long[] removeStat = new long[NUM_THREADS * NUM_TIMES_PER_THREAD];
   
       protected void setUp() throws Exception
       {
  @@ -43,7 +43,7 @@
           cache.getConfiguration().setCacheMode("local");
           cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
           configureCache();
  -        cache.startService();
  +      cache.start();
       }
   
       protected void tearDown() throws Exception
  @@ -51,7 +51,7 @@
           if (cache != null)
           {
               cache.remove("/");
  -            cache.stopService();
  +         cache.stop();
               cache = null;
               
               putStat = null;
  @@ -67,24 +67,27 @@
       protected void configureCache() throws Exception
       {
          Properties prop = new Properties();
  -       try{
  +      try
  +      {
             prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
  -       }catch(Exception e){
  +      }
  +      catch (Exception e)
  +      {
             System.out.println("Error loading jdbc properties ");
          }
          String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
  -                      "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") +"\n" +
  +              "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
                         "cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
                         "cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
                         "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type");
  -       cache.getConfiguration().setCacheLoaderConfiguration( getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false) );
  +      cache.getConfiguration().setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
       }
       
       public void testPut() throws Exception
       {
           Thread threads[] = new Thread[NUM_THREADS];
   
  -        for (int i=0; i<NUM_THREADS; i++)
  +      for (int i = 0; i < NUM_THREADS; i++)
           {
               long putStatSeg[] = new long [NUM_TIMES_PER_THREAD]; 
               threads[i] = new Thread()
  @@ -95,9 +98,9 @@
                   {
                       Fqn base = new Fqn(new Object[]{"Threads", getName()});
                       long start = System.currentTimeMillis();
  -                    for (int j=0; j<NUM_TIMES_PER_THREAD; j++)
  +                  for (int j = 0; j < NUM_TIMES_PER_THREAD; j++)
                       {
  -                        cache.put(base, "key"+j, "value"+j);
  +                     cache.put(base, "key" + j, "value" + j);
                           long timeTaken = System.currentTimeMillis() - start;
                           putStat[j] = timeTaken;
                       }
  @@ -135,9 +138,9 @@
                           long start = System.currentTimeMillis();
                           for (int j = 0; j < NUM_TIMES_PER_THREAD; j++)
                           {
  -                            cache.get(fqn, "key"+j);
  +                     cache.get(fqn, "key" + j);
                               long timeTaken = System.currentTimeMillis() - start;
  -                            getStat[j]=timeTaken;                            
  +                     getStat[j] = timeTaken;
                           }
                           
                       }
  @@ -175,7 +178,7 @@
                           long start = System.currentTimeMillis();
                           for (int j = 0; j < NUM_TIMES_PER_THREAD; j++)
                           {
  -                            cache.remove(fqn, "key"+j);
  +                     cache.remove(fqn, "key" + j);
                               cache.evict(fqn);
                               long timeTaken = System.currentTimeMillis() - start;
                               removeStat[j] = timeTaken;
  @@ -246,26 +249,28 @@
          System.out.println("  NumLoopsPerThread: " + NUM_TIMES_PER_THREAD);
          System.out.println("  Total time:        " + results.get("total"));
          System.out.println("  Avg time:          " + ((Long) results.get("total")).longValue() / stats.length);
  -       System.out.println("  shortest time:     " + ((Long)results.get("shortest")));
  +      System.out.println("  shortest time:     " + ((Long) results.get("shortest")));
          System.out.println("  longest time:      " + ((Long) results.get("longest")));
          
          System.out.println("------------------------------------");
       }
       
  -    public Map getStats ( long[] stats ){
  +   public Map getStats(long[] stats)
  +   {
          long statTotal = 0;
  -       long largest = 0 ;
  +      long largest = 0;
          long smallest = stats[0];
  -       for (int i = 0; i < stats.length; i++) {
  +      for (int i = 0; i < stats.length; i++)
  +      {
              statTotal = statTotal + stats[i];
  -           if (stats[i]>largest) largest = stats[i];
  -           if (stats[i]<smallest) smallest = stats[i];
  +         if (stats[i] > largest) largest = stats[i];
  +         if (stats[i] < smallest) smallest = stats[i];
          }
   
          Map results = new HashMap();
  -       results.put( "total",new Long( statTotal) );
  -       results.put( "shortest", new Long(smallest));
  -       results.put( "longest", new Long (largest));
  +      results.put("total", new Long(statTotal));
  +      results.put("shortest", new Long(smallest));
  +      results.put("longest", new Long(largest));
   
          return results;
      }
  
  
  



More information about the jboss-cvs-commits mailing list