[jbosscache-commits] JBoss Cache SVN: r6314 - in benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests: results and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Jul 17 07:47:22 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-17 07:47:22 -0400 (Thu, 17 Jul 2008)
New Revision: 6314

Added:
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/StatisticTest.java
Modified:
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/CacheTest.java
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/results/StatisticTestResult.java
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java
Log:
Added the ability to provide a "repeat" attribute on Statistic-related tests so you can have the test run many times and get an average

Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/CacheTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/CacheTest.java	2008-07-17 11:46:40 UTC (rev 6313)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/CacheTest.java	2008-07-17 11:47:22 UTC (rev 6314)
@@ -18,7 +18,7 @@
     * Called before {@link #doTest(String, org.cachebench.CacheWrapper, String, int, int)}.
     * Implemetations may cache this and further use on doTest method.
     */
-   public void setConfiguration(Configuration configuration);
+   void setConfiguration(Configuration configuration);
 
    /**
     * Performs the benchmarking on the given tese.
@@ -31,5 +31,5 @@
     * @return The result of the test.
     * @throws Exception When the cache opertations blow up an error.
     */
-   public TestResult doTest(String testName, CacheWrapper cache, String testCaseName, int sampleSize, int numThreads) throws Exception;
+   TestResult doTest(String testName, CacheWrapper cache, String testCaseName, int sampleSize, int numThreads) throws Exception;
 }

Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/StatisticTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/StatisticTest.java	                        (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/StatisticTest.java	2008-07-17 11:47:22 UTC (rev 6314)
@@ -0,0 +1,14 @@
+package org.cachebench.tests;
+
+import org.cachebench.CacheWrapper;
+import org.cachebench.tests.results.StatisticTestResult;
+
+/**
+ * Marker interface
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ */
+public interface StatisticTest
+{
+   void doCumulativeTest(String testName, CacheWrapper cache, String testCaseName, int sampleSize, int numThreads, StatisticTestResult str) throws Exception;
+}

Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/results/StatisticTestResult.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/results/StatisticTestResult.java	2008-07-17 11:46:40 UTC (rev 6313)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/results/StatisticTestResult.java	2008-07-17 11:47:22 UTC (rev 6314)
@@ -10,7 +10,7 @@
  */
 public class StatisticTestResult extends BaseTestResult
 {
-   private DescriptiveStatistics putData, getData;
+   private final DescriptiveStatistics putData = DescriptiveStatistics.newInstance(), getData = DescriptiveStatistics.newInstance();
    private int throughputTransactionsPerSecond;
    private int throughputBytesPerSecond;
    private int numMembers;
@@ -21,22 +21,11 @@
       return getData;
    }
 
-   public void setGetData(DescriptiveStatistics getData)
-   {
-      this.getData = getData;
-   }
-
    public DescriptiveStatistics getPutData()
    {
       return putData;
    }
 
-   public void setPutData(DescriptiveStatistics putData)
-   {
-      this.putData = putData;
-   }
-
-
    /**
     * This is only measured on put() operations as it has little meaning for get()s.
     */

Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java	2008-07-17 11:46:40 UTC (rev 6313)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java	2008-07-17 11:47:22 UTC (rev 6314)
@@ -8,6 +8,7 @@
 import org.cachebench.config.TestCase;
 import org.cachebench.config.TestConfig;
 import org.cachebench.tests.AbstractCacheTest;
+import org.cachebench.tests.StatisticTest;
 import org.cachebench.tests.results.StatisticTestResult;
 
 import java.io.ByteArrayOutputStream;
@@ -26,7 +27,7 @@
  * @author Manik Surtani (manik at surtani.org)
  *         (C) Manik Surtani, 2004
  */
-public abstract class SimpleTest extends AbstractCacheTest
+public abstract class SimpleTest extends AbstractCacheTest implements StatisticTest
 {
    protected Log log = LogFactory.getLog(this.getClass());
    protected AtomicLong numberOfBytesPut = new AtomicLong(0);
@@ -35,6 +36,7 @@
    private static final int EXECUTOR_SHUTDOWN_TIMEOUT_POLL_SECS = 60;
    protected Configuration configuration;
    protected final int LOG_FREQUENCY = 5000;
+   private StatisticTestResult results;
 
    private int getWritePercentageFromConfig(String testCaseName, String testName)
    {
@@ -51,6 +53,12 @@
       }
    }
 
+   public void doCumulativeTest(String testName, CacheWrapper cache, String testCaseName, int sampleSize, int numThreads, StatisticTestResult str) throws Exception
+   {
+      this.results = str;
+      doTest(testName, cache, testCaseName, sampleSize, numThreads);
+   }
+
    protected StatisticTestResult performTestWithObjectType(String testCaseName, CacheWrapper cache, Class valueClass, String testName, int sampleSize, int numThreads) throws Exception
    {
       writePercentage = getWritePercentageFromConfig(testCaseName, testName);
@@ -58,16 +66,14 @@
       log.info("Number of threads " + numThreads);
       executor = Executors.newFixedThreadPool(numThreads);
 
-      StatisticTestResult result = new StatisticTestResult();
+      StatisticTestResult result = results == null ? new StatisticTestResult() : results;
       result.setTestName(testCaseName + getNodeIndex());
       result.setTestTime(new Date());
       result.setTestType(testName);
 
       log.info("Performing test");
-      DescriptiveStatistics[] stats = doGetsAndPuts(cache, valueClass, sampleSize);
+      doGetsAndPuts(cache, valueClass, sampleSize, result.getGetData(), result.getPutData());
 
-      result.setGetData(stats[0]);
-      result.setPutData(stats[1]);
       result.setTestPassed(true); // The test is passed. The report would make use of this attribute.
 
       // calculate throughput, in transactions per second.
@@ -75,10 +81,10 @@
 
       // calc tps.
 
-      long elapsedSecondsForAllPuts = TimeUnit.NANOSECONDS.toSeconds((long) stats[1].getSum());
+      long elapsedSecondsForAllPuts = TimeUnit.NANOSECONDS.toSeconds((long) result.getPutData().getSum());
 
       System.out.println("*** sum of time: " + elapsedSecondsForAllPuts);
-      System.out.println("*** num puts occured: " + stats[1].getN());
+      System.out.println("*** num puts occured: " + result.getPutData().getN());
 
       try
       {
@@ -112,12 +118,10 @@
     * @param sampleSize The size of the cache.
     * @return The Descriptive statistics of the cache benchmarking.
     */
-   private DescriptiveStatistics[] doGetsAndPuts(final CacheWrapper cache, final Class valueClass, int sampleSize) throws Exception
+   private void doGetsAndPuts(final CacheWrapper cache, final Class valueClass, int sampleSize, final DescriptiveStatistics getStats, final DescriptiveStatistics putStats) throws Exception
    {
       log.debug("Inside doGets for : " + cache);
       final String key = "baseKey";
-      final DescriptiveStatistics getStats = DescriptiveStatistics.newInstance();
-      final DescriptiveStatistics putStats = DescriptiveStatistics.newInstance();
       Random rand = new Random();
       int modDivisor = 100 / writePercentage;
       numberOfBytesPut.set(0);
@@ -209,7 +213,6 @@
 
       // return the raw data
       log.debug("Leaving doTasks for : " + cache);
-      return new DescriptiveStatistics[]{getStats, putStats};
    }
 
    private void logOperation(int i, String s)




More information about the jbosscache-commits mailing list