[jbosscache-commits] JBoss Cache SVN: r5268 - in benchmarks/benchmark-fwk/trunk: conf and 2 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jan 30 20:18:57 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-01-30 20:18:57 -0500 (Wed, 30 Jan 2008)
New Revision: 5268

Added:
   benchmarks/benchmark-fwk/trunk/generateChart.sh
   benchmarks/benchmark-fwk/trunk/lib/jcommon.jar
   benchmarks/benchmark-fwk/trunk/lib/jfreechart.jar
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
Modified:
   benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh
   benchmarks/benchmark-fwk/trunk/conf/cachebench.xml
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java
Log:
Added chart generation


Modified: benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh	2008-01-31 00:25:05 UTC (rev 5267)
+++ benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh	2008-01-31 01:18:57 UTC (rev 5268)
@@ -15,7 +15,7 @@
 		do
 			./cluster.sh start $product $config $size
 
-			outputFileName=data-$product-$config-$size.csv
+			outputFileName=data_$product_$config_$size.csv
 
 			while [ ! -e $outputFileName ]
 			do
@@ -28,19 +28,3 @@
 		done
 	done
 done
-
-echo Combining reports
-
-cd output
-if [ -e ../combined.csv ]
-then
-	rm ../combined.csv
-fi
-
-for i in *.csv
-do
-	echo $i >> ../combined.csv
-	cat $i >> ../combined.csv
-	echo >> ../combined.csv	
-done
-

Modified: benchmarks/benchmark-fwk/trunk/conf/cachebench.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/conf/cachebench.xml	2008-01-31 00:25:05 UTC (rev 5267)
+++ benchmarks/benchmark-fwk/trunk/conf/cachebench.xml	2008-01-31 01:18:57 UTC (rev 5268)
@@ -8,7 +8,8 @@
 	emptyCacheBetweenTests - again, use if you're running out of mem.
 	numThreads - the number of executor threads to use to perform the required number of operations.  
 -->
-<cachebench sampleSize="10000" gcBetweenTestsEnabled="true" sleepBetweenTests="1000" emptyCacheBetweenTests="true" numThreads="10">
+<cachebench sampleSize="10000" gcBetweenTestsEnabled="true" sleepBetweenTests="1000" emptyCacheBetweenTests="true"
+            numThreads="10">
 
 
    <!--
@@ -21,13 +22,13 @@
    <cluster>
       <member host="cluster01" port="17900"/>
       <member host="cluster02" port="17900"/>
-      <member host="cluster03" port="17900"/> 
-      <member host="cluster04" port="17900"/> 
-      <member host="cluster05" port="17900"/> 
-      <member host="cluster06" port="17900"/> 
-      <member host="cluster07" port="17900"/> 
-      <member host="cluster08" port="17900"/> 
-      <member host="cluster09" port="17900"/> 
+      <member host="cluster03" port="17900"/>
+      <member host="cluster04" port="17900"/>
+      <member host="cluster05" port="17900"/>
+      <member host="cluster06" port="17900"/>
+      <member host="cluster07" port="17900"/>
+      <member host="cluster08" port="17900"/>
+      <member host="cluster09" port="17900"/>
       <member host="cluster10" port="17900"/>
    </cluster>
 
@@ -37,7 +38,7 @@
                           testcase. By default set to true.
    -->
 
-    <testcase name="WebSessionReplicationTest" stopOnFailure="true">
+   <testcase name="WebSessionReplicationTest" stopOnFailure="true">
 
       <!-- org.cachebench.warmup.PutGetCacheWarmup warms up the cache by doing operation on it; simulates a real-world environment.
       If no warmup is needed use org.cachebench.warmup.NoCacheWarmup
@@ -50,48 +51,48 @@
         validates that replication is enabled and works. If repl does not occur and the stopOnFailure is set to true then exists.
         Should be used to make sure that replication is enabled; see javadoc for more details
       -->
-	<!--
-      <test name="replicationOccurrsTest" testClass="org.cachebench.tests.ReplicationOccursTest">
-         <param name="partialReplication" value="true"/>
-      </test>
+      <!--
+            <test name="replicationOccurrsTest" testClass="org.cachebench.tests.ReplicationOccursTest">
+               <param name="partialReplication" value="true"/>
+            </test>
 
--->
+      -->
       <!--
          * The "name" attrib is just used for display in the reports.
          * You can write your own custom testClass.
          * weight is currently unused.
       -->
-       <!--<test name="Strings" testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0" />-->
-       
-       <test name="SessionSimulator" testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0" >
-          <param name="numberOfRequest" value="100000"/>
-          <param name="numberOfAttributes" value="100"/>
-          <param name="writePercentage" value="20"/>
-          <param name="sizeOfAnAttribute" value="1000"/>
-       </test>
+      <!--<test name="Strings" testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0" />-->
 
-       <!--
-      <test name="Primitive Wrappers" testClass="org.cachebench.tests.simpletests.PrimitiveTest" weight="1.0" />
-		<test name="Custom Class Types" testClass="org.cachebench.tests.simpletests.CustomClassTest" weight="1.0" />
-		<test name="Custom Subclasses of Abstracts" testClass="org.cachebench.tests.simpletests.SubclassTest" weight="1.5" />
-		<test name="Custom Types With Transients" testClass="org.cachebench.tests.simpletests.TransientTest" weight="1.0" />
-		<test name="Custom Types With Statics" testClass="org.cachebench.tests.simpletests.StaticsTest" weight="1.5" />
-		<test name="Custom Types With Associations" testClass="org.cachebench.tests.simpletests.AssociationsTest" weight="2.0" />
-		-->
+      <test name="SessionSimulator" testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0">
+         <param name="numberOfRequest" value="100000"/>
+         <param name="numberOfAttributes" value="100"/>
+         <param name="writePercentage" value="20"/>
+         <param name="sizeOfAnAttribute" value="1000"/>
+      </test>
 
-       <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored.  Please pass in your cache config
-                      file name that you wish to use with the -DcacheBenchFwk.cacheConfigFile JVM parameter.  The runNode.sh
-                      and cluster.sh scripts will also do this for you.  -->
+      <!--
+        <test name="Primitive Wrappers" testClass="org.cachebench.tests.simpletests.PrimitiveTest" weight="1.0" />
+        <test name="Custom Class Types" testClass="org.cachebench.tests.simpletests.CustomClassTest" weight="1.0" />
+        <test name="Custom Subclasses of Abstracts" testClass="org.cachebench.tests.simpletests.SubclassTest" weight="1.5" />
+        <test name="Custom Types With Transients" testClass="org.cachebench.tests.simpletests.TransientTest" weight="1.0" />
+        <test name="Custom Types With Statics" testClass="org.cachebench.tests.simpletests.StaticsTest" weight="1.5" />
+        <test name="Custom Types With Associations" testClass="org.cachebench.tests.simpletests.AssociationsTest" weight="2.0" />
+        -->
+
+      <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored.  Please pass in your cache config
+file name that you wish to use with the -DcacheBenchFwk.cacheConfigFile JVM parameter.  The runNode.sh
+and cluster.sh scripts will also do this for you.  -->
    </testcase>
 
 
-	<!--
-	   Available generators are: CSVReportGenerator and ClusterReportGenerator.
-	   See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
-		own report generators such as XML generators, graphic generators, etc
+   <!--
+      Available generators are: CSVReportGenerator and ClusterReportGenerator.
+      See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
+      own report generators such as XML generators, graphic generators, etc
    -->
    <!-- The CSV report generated can be plugged in to a spreadsheet to generate graphs. If 'outputFile is set to
-   '-generic-' then the name would be generated as follows: 'data-<cache-product>-<configuration>-<cluster-size>.csv' -->
+   '-generic-' then the name would be generated as follows: 'data_<cache-product>_<configuration>_<cluster-size>.csv' -->
    <report outputFile="-generic-" generator="org.cachebench.reportgenerators.ClusterReportGenerator"/>
 
 </cachebench>

Added: benchmarks/benchmark-fwk/trunk/generateChart.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/generateChart.sh	                        (rev 0)
+++ benchmarks/benchmark-fwk/trunk/generateChart.sh	2008-01-31 01:18:57 UTC (rev 5268)
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+CP=.
+
+for i in lib/*.java
+do
+   CP=$CP:$i
+done
+
+java -cp $CP org.cachebench.reportgenerators.ChartGenerator ${*}

Added: benchmarks/benchmark-fwk/trunk/lib/jcommon.jar
===================================================================
(Binary files differ)


Property changes on: benchmarks/benchmark-fwk/trunk/lib/jcommon.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: benchmarks/benchmark-fwk/trunk/lib/jfreechart.jar
===================================================================
(Binary files differ)


Property changes on: benchmarks/benchmark-fwk/trunk/lib/jfreechart.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java	2008-01-31 00:25:05 UTC (rev 5267)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java	2008-01-31 01:18:57 UTC (rev 5268)
@@ -32,9 +32,9 @@
 
    private String getFileName(String fileName)
    {
-      if (fileName.indexOf("-generic-") >=0 )
+      if (fileName.indexOf("-generic-") >= 0)
       {
-         return "data-" + params.get("cacheProductName") + "-" + params.get("config") + "-" + params.get("clusterSize") + ".csv";
+         return "data_" + params.get("cacheProductName") + "_" + params.get("config") + "_" + params.get("clusterSize") + ".csv";
       }
       log.info("Filename for report generation is: " + fileName);
       return fileName;

Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java	                        (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java	2008-01-31 01:18:57 UTC (rev 5268)
@@ -0,0 +1,147 @@
+package org.cachebench.reportgenerators;
+
+import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.StringTokenizer;
+
+/**
+ * Manual chart generator.  Grabs CSVs generated by {@link org.cachebench.reportgenerators.ClusterReportGenerator} and spits out
+ * line graphs.
+ * <p/>
+ * This generator draws line graphs, using cluster size on the X axis (e.g., 2, 4, 6 nodes) and throughput (requests per second)
+ * on the Y axis.  It then plots points for the different cache products and configurations tested.
+ * <p/>
+ * For the time being, this is expected to be run manually on the command line, passing in relevant parameters.  Calling this with
+ * no params will generate some help.
+ * <p/>
+ * TODO: Make this a proper report generator plugin once we have proper report consolidation that spans multiple runs for different cluster sizes and cache products.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ */
+public class ChartGenerator
+{
+   static String reportDirectory;
+   static boolean singleChart;
+   DefaultCategoryDataset dataset;
+
+
+   private static void help()
+   {
+      System.out.println("Usage:");
+      System.out.println("   ChartGenerator [-reportDir <directory containing CSV files>] [-singleChart <true | false> if true, generates a single chart for all config files.]");
+   }
+
+   public static void main(String[] args) throws IOException
+   {
+      System.out.println("Welcome to the ChartGenerator.");
+      // the params we expect:
+      for (int i = 0; i < args.length; i++)
+      {
+         if (args[i].equals("-reportDir"))
+         {
+            reportDirectory = args[++i];
+            continue;
+         }
+
+         if (args[i].equals("-singleChart"))
+         {
+            singleChart = Boolean.valueOf(args[++i]);
+            continue;
+         }
+
+         help();
+         return;
+      }
+
+      new ChartGenerator().generateChart();
+   }
+
+   private void generateChart() throws IOException
+   {
+      readData();
+      JFreeChart chart = ChartFactory.createLineChart("CacheBenchFwk Report", "Cluster size", "Throughput (reqs/sec)",
+            dataset, PlotOrientation.HORIZONTAL, true, false, false);
+
+      chart.setSubtitles(Collections.singletonList("" + new Date()));
+      ChartUtilities.saveChartAsPNG(new File("chart.png"), chart, 600, 800);
+   }
+
+   private void readData() throws IOException
+   {
+      File file = new File(reportDirectory);
+      if (!file.exists() || !file.isDirectory())
+         throw new IllegalArgumentException("Report directory " + reportDirectory + " does not exist or is not a directory!");
+
+      File[] files = file.listFiles(new FilenameFilter()
+      {
+         public boolean accept(File dir, String name)
+         {
+            return name.toUpperCase().endsWith(".CSV");
+         }
+      });
+
+      dataset = new DefaultCategoryDataset();
+      for (File f : files)
+      {
+         readData(f);
+      }
+   }
+
+   private void readData(File f) throws IOException
+   {
+      // chop up the file name to get productAndConfiguration and clusterSize.
+      Integer clusterSize = 0;
+      DescriptiveStatistics stats = DescriptiveStatistics.newInstance();
+      // file name is in the format data_<cache-product>_<cache-cfg.xml>_<cluster-size>.csv
+
+      StringTokenizer strtok = new StringTokenizer(f.getName(), "_");
+      strtok.nextToken(); // this is the "data-" bit
+      String productNameAndConfiguration = strtok.nextToken() + "(" + strtok.nextToken();
+      // chop off the trailing ".xml"
+      if (productNameAndConfiguration.toUpperCase().endsWith(".XML"))
+         productNameAndConfiguration = productNameAndConfiguration.substring(0, productNameAndConfiguration.length() - 4);
+      productNameAndConfiguration += ")";
+
+      // cluster size
+      String cS = strtok.nextToken();
+      if (cS.toUpperCase().endsWith(".CSV")) cS = cS.substring(0, cS.length() - 4);
+      clusterSize = Integer.parseInt(cS);
+
+      // now read the data.
+      String line = null;
+      BufferedReader br = new BufferedReader(new FileReader(f));
+      while ((line = br.readLine()) != null)
+      {
+         double throughput = getThroughput(line);
+         if (throughput != -1) stats.addValue(throughput);
+      }
+
+      dataset.addValue(stats.getMean(), productNameAndConfiguration, clusterSize);
+   }
+
+   private double getThroughput(String line)
+   {
+      // To be a valid line, the line should be comma delimited
+      StringTokenizer strTokenizer = new StringTokenizer(line, ",");
+      if (strTokenizer.countTokens() < 2) return -1;
+
+      // we want the 3rd element which is throughput
+      strTokenizer.nextToken();
+      strTokenizer.nextToken();
+      String candidate = strTokenizer.nextToken();
+      return Double.parseDouble(candidate);
+   }
+
+}




More information about the jbosscache-commits mailing list