[jbosscache-commits] JBoss Cache SVN: r6316 - in benchmarks/benchmark-fwk/trunk/src/org/cachebench: config and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Thu Jul 17 07:51:11 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-07-17 07:51:11 -0400 (Thu, 17 Jul 2008)
New Revision: 6316
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/TestConfig.java
Log:
Updated sample cfg
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2008-07-17 11:49:04 UTC (rev 6315)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2008-07-17 11:51:11 UTC (rev 6316)
@@ -14,7 +14,9 @@
import org.cachebench.reportgenerators.ReportGenerator;
import org.cachebench.tests.CacheTest;
import org.cachebench.tests.ClusteredCacheTest;
+import org.cachebench.tests.StatisticTest;
import org.cachebench.tests.results.BaseTestResult;
+import org.cachebench.tests.results.StatisticTestResult;
import org.cachebench.tests.results.TestResult;
import org.cachebench.utils.Instantiator;
import org.cachebench.warmup.CacheWarmup;
@@ -35,7 +37,7 @@
{
private Configuration conf;
- private Log logger = LogFactory.getLog(CacheBenchmarkRunner.class);
+ private Log log = LogFactory.getLog(CacheBenchmarkRunner.class);
private Log errorLogger = LogFactory.getLog("CacheException");
// information about how we are called:
@@ -91,16 +93,16 @@
URL confFile = ConfigBuilder.findConfigFile(s);
if (confFile == null)
{
- logger.warn("Unable to locate a configuration file; Application terminated");
+ log.warn("Unable to locate a configuration file; Application terminated");
}
else
{
- if (logger.isDebugEnabled()) logger.debug("Using configuration " + confFile);
- logger.debug("Parsing configuration");
+ if (log.isDebugEnabled()) log.debug("Using configuration " + confFile);
+ log.debug("Parsing configuration");
try
{
conf = ConfigBuilder.parseConfiguration(confFile);
- logger.info("Starting Benchmarking....");
+ log.info("Starting Benchmarking....");
List<TestResult> results = runTests(); // Run the tests from this point.
if (results != null && results.size() != 0)
{
@@ -108,24 +110,38 @@
}
else
{
- logger.warn("No Results to be reported");
+ log.warn("No Results to be reported");
}
- logger.info("Benchmarking Completed. Hope you enjoyed using this! \n");
+ log.info("Benchmarking Completed. Hope you enjoyed using this! \n");
}
catch (Throwable e)
{
- logger.warn("Unable to parse configuration file " + confFile + ". Application terminated", e);
+ log.warn("Unable to parse configuration file " + confFile + ". Application terminated", e);
errorLogger.fatal("Unable to parse configuration file " + confFile, e);
}
}
}
+ CacheWrapper newCache(TestCase test) throws Exception
+ {
+ CacheWrapper cache = getCacheWrapperInstance(test);
+ if (cache != null)
+ {
+ Map<String, String> params = test.getParams();
+ // now add the config file, if any is passed in:
+ params.putAll(systemParams);
+ log.info("Initialising cache with params " + params);
+ cache.init(params);
+ }
+ return cache;
+ }
+
/**
* Executes each test case and returns the result.
*
* @return The Array of TestResult objects with the results of the tests.
*/
- private List<TestResult> runTests()
+ private List<TestResult> runTests() throws Exception
{
List<TestResult> results = new ArrayList<TestResult>();
for (TestCase test : conf.getTestCases())
@@ -133,14 +149,9 @@
CacheWrapper cache = null;
try
{
- cache = getCacheWrapperInstance(test);
+ cache = newCache(test);
if (cache != null)
{
- Map<String, String> params = test.getParams();
- // now add the config file, if any is passed in:
- params.putAll(systemParams);
- logger.info("Initialising cache with params " + params);
- cache.init(params);
if (!localOnly) barrier("BEFORE_WARMUP");
warmupCache(test, cache);
if (!localOnly) barrier("AFTER_WARMUP");
@@ -163,7 +174,7 @@
{
//ignore
}
- logger.warn("Unable to Initialize or Setup the Cache - Not performing any tests", e);
+ log.warn("Unable to Initialize or Setup the Cache - Not performing any tests", e);
errorLogger.error("Unable to Initialize or Setup the Cache: " + test.getCacheWrapper(), e);
errorLogger.error("Skipping this test");
}
@@ -174,23 +185,23 @@
private void barrier(String messageName) throws Exception
{
ClusterBarrier barrier = new ClusterBarrier();
- logger.trace("Using following cluster config: " + conf.getClusterConfig());
+ log.trace("Using following cluster config: " + conf.getClusterConfig());
barrier.setConfig(conf.getClusterConfig());
barrier.setAcknowledge(true);
barrier.barrier(messageName);
- logger.info("Barrier for '" + messageName + "' finished");
+ log.info("Barrier for '" + messageName + "' finished");
}
private void warmupCache(TestCase test, CacheWrapper cache) throws Exception
{
- logger.info("Warming up..");
+ log.info("Warming up..");
CacheWarmupConfig warmupConfig = test.getCacheWarmupConfig();
- logger.trace("Warmup config is: " + warmupConfig);
+ log.trace("Warmup config is: " + warmupConfig);
CacheWarmup warmup = (CacheWarmup) Instantiator.getInstance().createClass(warmupConfig.getWarmupClass());
warmup.setConfigParams(warmupConfig.getParams());
warmup.warmup(cache);
- logger.info("Warmup ended!");
+ log.info("Warmup ended!");
}
/**
@@ -237,7 +248,7 @@
CacheTest testInstance = getCacheTest(testConfig);
if (testInstance instanceof ClusteredCacheTest && localOnly)
{
- logger.warn("Skipping replicated tests since this is in local mode!");
+ log.warn("Skipping replicated tests since this is in local mode!");
continue;
}
@@ -248,7 +259,38 @@
String testCaseName = testCase.getName();
try
{
- result = testInstance.doTest(testName, cache, testCaseName, conf.getSampleSize(), conf.getNumThreads());
+ if (testInstance instanceof StatisticTest)
+ {
+ // create new DescriptiveStatistics and pass it to the test
+ int repeat = testConfig.getRepeat();
+ if (log.isInfoEnabled()) log.info("Running test " + repeat + " times");
+ StatisticTestResult str = new StatisticTestResult();
+ for (int i = 0; i < repeat; i++)
+ {
+ ((StatisticTest) testInstance).doCumulativeTest(testName, cache, testCaseName, conf.getSampleSize(), conf.getNumThreads(), str);
+ if (conf.isEmptyCacheBetweenTests())
+ {
+ if (conf.isLocalOnly())
+ {
+ // destroy and restart the cache
+ shutdownCache(cache);
+ if (i != repeat - 1) cache = newCache(testCase);
+ }
+ else
+ cache.empty();
+ }
+ if (conf.isGcBetweenTestsEnabled())
+ {
+ System.gc();
+ Thread.sleep(conf.getSleepBetweenTests());
+ }
+ }
+ result = str;
+ }
+ else
+ {
+ result = testInstance.doTest(testName, cache, testCaseName, conf.getSampleSize(), conf.getNumThreads());
+ }
}
catch (Exception e)
{
@@ -260,12 +302,12 @@
result.setTestPassed(false);
result.setErrorMsg("Failed to Execute - See logs for details : " + e.getMessage());
- logger.warn("Test case : " + testCaseName + ", Test : " + testName + " - Failed due to", e);
+ log.warn("Test case : " + testCaseName + ", Test : " + testName + " - Failed due to", e);
errorLogger.error("Test case : " + testCaseName + ", Test : " + testName + " - Failed : " + e.getMessage(), e);
}
if (!result.isTestPassed() && testCase.isStopOnFailure())
{
- logger.warn("The test '" + testCase + "/" + testName + "' failed, exiting...");
+ log.warn("The test '" + testCase + "/" + testName + "' failed, exiting...");
System.exit(1);
}
executeTestTasks(cache, result);
@@ -280,7 +322,7 @@
private void generateReports(List<TestResult> results)
{
- logger.info("Generating Reports...");
+ log.info("Generating Reports...");
for (Report report : conf.getReports())
{
ReportGenerator generator;
@@ -298,17 +340,17 @@
generator.setClusterConfig(conf.getClusterConfig());
generator.setOutputFile(report.getOutputFile());
generator.generate();
- logger.info("Report Generation Completed");
+ log.info("Report Generation Completed");
}
else
{
- logger.info("Report not generated - See logs for reasons!!");
+ log.info("Report not generated - See logs for reasons!!");
}
}
catch (Exception e)
{
- logger.warn("Unable to generate Report : " + report.getGenerator() + " - See logs for reasons");
- logger.warn("Skipping this report");
+ log.warn("Unable to generate Report : " + report.getGenerator() + " - See logs for reasons");
+ log.warn("Skipping this report");
errorLogger.error("Unable to generate Report : " + report.getGenerator(), e);
errorLogger.error("Skipping this report");
}
@@ -325,7 +367,7 @@
}
catch (Exception e)
{
- logger.warn("Unable to instantiate CacheWrapper class: " + testCaseClass.getCacheWrapper() + " - Not Running any tests");
+ log.warn("Unable to instantiate CacheWrapper class: " + testCaseClass.getCacheWrapper() + " - Not Running any tests");
errorLogger.error("Unable to instantiate CacheWrapper class: " + testCaseClass.getCacheWrapper(), e);
errorLogger.error("Skipping this test");
}
@@ -342,7 +384,7 @@
}
catch (Exception e)
{
- logger.warn("Unable to instantiate ReportGenerator class: " + reportClass.getGenerator() + " - Not generating the report");
+ log.warn("Unable to instantiate ReportGenerator class: " + reportClass.getGenerator() + " - Not generating the report");
errorLogger.error("Unable to instantiate ReportGenerator class: " + reportClass.getGenerator(), e);
errorLogger.error("Skipping this report");
}
@@ -361,7 +403,7 @@
}
catch (Exception e)
{
- logger.warn("Unable to instantiate CacheTest class: " + testConfig.getTestClass() + " - Not Running any tests");
+ log.warn("Unable to instantiate CacheTest class: " + testConfig.getTestClass() + " - Not Running any tests");
errorLogger.error("Unable to instantiate CacheTest class: " + testConfig.getTestClass(), e);
errorLogger.error("Skipping this Test");
}
@@ -377,7 +419,7 @@
}
catch (Exception e)
{
- logger.warn("Cache Shutdown - Failed.");
+ log.warn("Cache Shutdown - Failed.");
errorLogger.error("Cache Shutdown failed : ", e);
}
}
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/TestConfig.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/TestConfig.java 2008-07-17 11:49:04 UTC (rev 6315)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/TestConfig.java 2008-07-17 11:51:11 UTC (rev 6316)
@@ -6,6 +6,7 @@
private String name;
private String testClass;
private float weight;
+ private int repeat = 1;
/**
@@ -55,4 +56,14 @@
{
this.weight = weight;
}
+
+ public int getRepeat()
+ {
+ return repeat;
+ }
+
+ public void setRepeat(int repeat)
+ {
+ this.repeat = repeat;
+ }
}
\ No newline at end of file
More information about the jbosscache-commits
mailing list