[jbosscache-commits] JBoss Cache SVN: r5771 - core/trunk/src/test/java/org/jboss/cache/profiling.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Apr 30 10:04:04 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-30 10:04:04 -0400 (Wed, 30 Apr 2008)
New Revision: 5771

Modified:
   core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
   core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java
   core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
Improved profiling tests

Modified: core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java	2008-04-30 12:17:13 UTC (rev 5770)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java	2008-04-30 14:04:04 UTC (rev 5771)
@@ -41,4 +41,12 @@
    public abstract void testReplSyncOptBR() throws Exception;
 
    public abstract void testReplAsyncOptBR() throws Exception;
+
+   public abstract void testStateTransfer() throws Exception;
+
+   public abstract void testStartup() throws Exception;
+
+   public abstract void testCacheLoading() throws Exception;
+
+   public abstract void testPassivation() throws Exception;
 }

Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java	2008-04-30 12:17:13 UTC (rev 5770)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java	2008-04-30 14:04:04 UTC (rev 5771)
@@ -82,4 +82,28 @@
       cache.getConfiguration().setBuddyReplicationConfig(brc);
       testReplAsyncOptimistic();
    }
+
+   public void testStateTransfer() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
+
+   public void testStartup() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
+
+   public void testCacheLoading() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
+
+   public void testPassivation() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java	2008-04-30 12:17:13 UTC (rev 5770)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java	2008-04-30 14:04:04 UTC (rev 5771)
@@ -36,12 +36,12 @@
    /*
       Test configuration options
     */
-   protected static final long DURATION = 5 * 60 * 1000;
-   protected static final int NUM_THREADS = 5;
-   protected static final int MAX_RANDOM_SLEEP_MILLIS = 50;
-   protected static final int MAX_DEPTH = 4;
-   protected static final int MAX_OVERALL_NODES = 100;
-   protected static final int WARMUP_LOOPS = 10000;
+   protected static final long DURATION = 10 * 60 * 1000; // 15 mins
+   protected static final int NUM_THREADS = 15;
+   protected static final int MAX_RANDOM_SLEEP_MILLIS = 25;
+   protected static final int MAX_DEPTH = 3;
+   protected static final int MAX_OVERALL_NODES = 200;
+   protected static final int WARMUP_LOOPS = 20000;
 
    private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_NODES);
    private Random r = new Random();
@@ -163,28 +163,45 @@
       log.warn("Started cache.  " + printDuration(duration));
    }
 
-   private void warmup()
+   private void warmup() throws InterruptedException
    {
       long startTime = System.currentTimeMillis();
+      ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
       log.warn("Starting warmup");
       // creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
-      for (Fqn f : fqns)
+      for (final Fqn f : fqns)
       {
-         // this will create the necessary nodes.
-         cache.put(f, Collections.emptyMap());
+         exec.execute(new Runnable()
+         {
+            public void run()
+            {
+               // this will create the necessary nodes.
+               cache.put(f, Collections.emptyMap());
+            }
+         });
       }
 
       // loop through WARMUP_LOOPS gets and puts for JVM optimisation
       for (int i = 0; i < WARMUP_LOOPS; i++)
       {
-         Fqn f = fqns.get(r.nextInt(MAX_OVERALL_NODES));
-         cache.get(f, "");
-         cache.put(f, "k", "v");
-         cache.remove(f, "k");
+         exec.execute(new Runnable()
+         {
+            public void run()
+            {
+               Fqn f = fqns.get(r.nextInt(MAX_OVERALL_NODES));
+               cache.get(f, "");
+               cache.put(f, "k", "v");
+               cache.remove(f, "k");
+            }
+         });
       }
 
+      exec.shutdown();
+      exec.awaitTermination(360, TimeUnit.SECONDS);
+
       long duration = System.currentTimeMillis() - startTime;
       log.warn("Finished warmup.  " + printDuration(duration));
+      cache.removeNode(Fqn.ROOT);
    }
 
    private void doTest() throws Exception
@@ -196,35 +213,87 @@
       int i = 0;
       while (System.currentTimeMillis() < end)
       {
-         exec.execute(new MyRunnable(i++));
+         MyRunnable r = null;
+         switch (i % 3)
+         {
+            case 0:
+               r = new Putter(i++);
+               break;
+            case 1:
+               r = new Getter(i++);
+               break;
+            case 2:
+               r = new Remover(i++);
+               break;
+         }
+         exec.execute(r);
          TestingUtil.sleepRandom(MAX_RANDOM_SLEEP_MILLIS);
       }
       log.warn("Finished generating runnables; awaiting executor completion");
       // wait for executors to complete!
       exec.shutdown();
-      exec.awaitTermination(10000, TimeUnit.MILLISECONDS);
+      exec.awaitTermination(((long) i) * 250, TimeUnit.MILLISECONDS);  // wait up to 250 millis for each call?
       long duration = System.currentTimeMillis() - startTime;
       log.warn("Finished test.  " + printDuration(duration));
    }
 
-   private class MyRunnable implements Runnable
+   enum Mode
    {
+      PUT, GET, REMOVE
+   }
+
+   private abstract class MyRunnable implements Runnable
+   {
       int id;
+      Mode mode;
 
-      private MyRunnable(int id)
+      public void run()
       {
+         if (id % 100 == 0) log.warn("Processing iteration " + id);
+         String k = getRandomString();
+         Fqn f = fqns.get(r.nextInt(MAX_OVERALL_NODES));
+         switch (mode)
+         {
+            case PUT:
+               cache.put(f, k, getRandomString());
+               break;
+            case GET:
+               cache.get(f, k);
+               break;
+            case REMOVE:
+               cache.remove(f, k);
+               break;
+         }
+      }
+   }
+
+   private class Putter extends MyRunnable
+   {
+      private Putter(int id)
+      {
          this.id = id;
+         mode = Mode.PUT;
       }
+   }
 
-      public void run()
+   private class Getter extends MyRunnable
+   {
+      private Getter(int id)
       {
-         if (id % 100 == 0) log.warn("Processing iteration " + id);
-         String k = getRandomString();
-         String v = getRandomString();
-         cache.put(fqns.get(r.nextInt(MAX_OVERALL_NODES)), k, v);
+         this.id = id;
+         mode = Mode.GET;
       }
    }
 
+   private class Remover extends MyRunnable
+   {
+      private Remover(int id)
+      {
+         this.id = id;
+         mode = Mode.REMOVE;
+      }
+   }
+
    private String getRandomString()
    {
       StringBuilder sb = new StringBuilder();
@@ -249,4 +318,28 @@
          return "Duration: " + duration + " millis";
       }
    }
+
+   public void testStateTransfer() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
+
+   public void testStartup() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
+
+   public void testCacheLoading() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
+
+   public void testPassivation() throws Exception
+   {
+      // TODO implement me
+      throw new Exception("Implement me");
+   }
 }




More information about the jbosscache-commits mailing list