Author: manik.surtani(a)jboss.com
Date: 2008-05-12 12:18:11 -0400 (Mon, 12 May 2008)
New Revision: 5828
Added:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
Log:
Added more charts
Added:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java
(rev 0)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java 2008-05-12
16:18:11 UTC (rev 5828)
@@ -0,0 +1,18 @@
+package org.cachebench.reportgenerators;
+
+public abstract class AbstractChartGen implements ChartGen
+{
+ protected String reportDirectory;
+ protected String filenamePrefix;
+
+ public void setReportDirectory(String reportDirectory)
+ {
+ this.reportDirectory = reportDirectory;
+ }
+
+
+ public void setFileNamePrefix(String fnPrefix)
+ {
+ this.filenamePrefix = fnPrefix;
+ }
+}
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java
(rev 0)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java 2008-05-12
16:18:11 UTC (rev 5828)
@@ -0,0 +1,18 @@
+package org.cachebench.reportgenerators;
+
+import java.io.IOException;
+
+/**
+ * Chart generator interface
+ *
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ */
+public interface ChartGen
+{
+
+ void setReportDirectory(String reportDirectory);
+
+ void setFileNamePrefix(String fnPrefix);
+
+ void generateChart() throws IOException;
+}
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java 2008-05-12
11:37:20 UTC (rev 5827)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java 2008-05-12
16:18:11 UTC (rev 5828)
@@ -1,25 +1,6 @@
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.chart.title.TextTitle;
-import org.jfree.data.category.CategoryDataset;
-import org.jfree.data.category.DefaultCategoryDataset;
-
-import java.awt.*;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
/**
* Manual chart generator. Grabs CSVs generated by {@link
org.cachebench.reportgenerators.ClusterReportGenerator} and spits out
@@ -37,21 +18,19 @@
*/
public class ChartGenerator
{
- static String reportDirectory;
- static boolean singleChart = true;
- DefaultCategoryDataset averageThroughput, totalThroughput;
- static String fnPrefix = null;
- static String chartNameAverage = "chart-averageThroughput.png",
chartNameTotal = "chart-totalThroughput.png";
-
-
private static void help()
{
System.out.println("Usage:");
- System.out.println(" ChartGenerator [-reportDir <directory containing CSV
files>] [-o <outputFileNamePrefix>] [-singleChart <true | false> if true,
generates a single chart for all config files.]");
+ System.out.println(" ChartGenerator [-reportDir <directory containing CSV
files>] [-o <outputFileNamePrefix>] [-singleChart <true | false> if true,
generates a single chart for all config files.] [-chartType <putget | throughput>
defaults to throughput if not specified.]");
}
public static void main(String[] args) throws IOException
{
+ String reportDirectory = null;
+ boolean singleChart = true;
+ String fnPrefix = null;
+ String chartType = "throughput";
+
long startTime = System.currentTimeMillis();
System.out.println("Welcome to the ChartGenerator.");
// the params we expect:
@@ -75,6 +54,12 @@
continue;
}
+ if (args[i].equals("-chartType"))
+ {
+ chartType = args[++i];
+ continue;
+ }
+
help();
return;
}
@@ -85,157 +70,21 @@
return;
}
if (!singleChart) throw new RuntimeException("Multiple charts not yet
implemented");
- new ChartGenerator().generateChart();
- System.out.println("Finished in " + ((System.currentTimeMillis() -
startTime) / 1000) + " seconds!");
- }
- private void generateChart() throws IOException
- {
- readData();
+ ChartGen gen;
- String chartAvgFileName = fnPrefix == null ? chartNameAverage : fnPrefix +
"-" + chartNameAverage;
- File chartFile = new File(chartAvgFileName);
- if (chartFile.exists())
+ if (chartType.equalsIgnoreCase("putget"))
{
- chartFile.renameTo(new File(chartAvgFileName + "." +
System.currentTimeMillis()));
- chartFile = new File(chartAvgFileName);
+ gen = new PutGetChartGenerator();
}
-
- ChartUtilities.saveChartAsPNG(chartFile, createChart(averageThroughput,
"Report: Average throughput per cache instance", "Throughput per cache
instance (reqs/sec)"), 1024, 768);
-
- String chartTotalFileName = fnPrefix == null ? chartNameTotal : fnPrefix +
"-" + chartNameTotal;
- chartFile = new File(chartTotalFileName);
- if (chartFile.exists())
+ else
{
- chartFile.renameTo(new File(chartTotalFileName + "." +
System.currentTimeMillis()));
- chartFile = new File(chartTotalFileName);
+ gen = new ThroughputChartGenerator();
}
- ChartUtilities.saveChartAsPNG(chartFile, createChart(totalThroughput, "Report:
Total throughput for cluster", "Overall throughput (reqs/sec)"), 1024,
768);
-
- System.out.println("Charts saved as " + chartAvgFileName + " and
" + chartTotalFileName);
+ gen.setReportDirectory(reportDirectory);
+ gen.setFileNamePrefix(fnPrefix);
+ gen.generateChart();
+ System.out.println("Finished in " + ((System.currentTimeMillis() -
startTime) / 1000) + " seconds!");
}
-
- private JFreeChart createChart(CategoryDataset data, String title, String yLabel)
- {
- JFreeChart chart = ChartFactory.createLineChart(title, "Cluster size (number
of cache instances)", yLabel, data, PlotOrientation.VERTICAL, true, false, false);
- chart.addSubtitle(new TextTitle("Generated on " + new Date() + " by
The CacheBenchFwk"));
- chart.setBorderVisible(true);
- chart.setAntiAlias(true);
- chart.setTextAntiAlias(true);
- chart.setBackgroundPaint(new Color(0x61, 0x9e, 0xa1));
- return chart;
- }
-
- 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");
- }
- });
-
- averageThroughput = new DefaultCategoryDataset();
- totalThroughput = new DefaultCategoryDataset();
- for (File f : files)
- {
- readData(f);
- }
-
- sort(averageThroughput);
- sort(totalThroughput);
- }
-
- /**
- * Crappy that the JFReechart data set doesn't order columns and rows by default
or even as an option. Need to do this manually.
- *
- * @param data
- */
- private void sort(DefaultCategoryDataset data)
- {
- SortedMap<Comparable, SortedMap<Comparable, Number>> raw = new
TreeMap<Comparable, SortedMap<Comparable, Number>>();
- for (int i = 0; i < data.getRowCount(); i++)
- {
- Comparable row = data.getRowKey(i);
- SortedMap<Comparable, Number> rowData = new TreeMap<Comparable,
Number>();
- for (int j = 0; j < data.getColumnCount(); j++)
- {
- Comparable column = data.getColumnKey(j);
- Number value = data.getValue(i, j);
- rowData.put(column, value);
- }
- raw.put(row, rowData);
- }
-
- data.clear();
- for (Comparable row : raw.keySet())
- {
- Map<Comparable, Number> rowData = raw.get(row);
- for (Comparable column : rowData.keySet())
- {
- data.addValue(rowData.get(column), row, column);
- }
- }
- }
-
-
- 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);
- }
-
- averageThroughput.addValue(stats.getMean(), productNameAndConfiguration,
clusterSize);
- totalThroughput.addValue(stats.getSum(), 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();
- try
- {
- return Double.parseDouble(candidate);
- }
- catch (NumberFormatException nfe)
- {
- return -1;
- }
- }
-
}
Added:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java
(rev 0)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java 2008-05-12
16:18:11 UTC (rev 5828)
@@ -0,0 +1,190 @@
+package org.cachebench.reportgenerators;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.labels.CategoryItemLabelGenerator;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.BarRenderer3D;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import java.awt.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.text.NumberFormat;
+import java.util.Date;
+import java.util.StringTokenizer;
+
+/**
+ * Generates average and total throughput. Used for parsing reports generated with a
ClusterReportGenerator.
+ *
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ */
+public class PutGetChartGenerator extends AbstractChartGen
+{
+ private DefaultCategoryDataset putData, getData;
+ private String putChartName = "PutChart.png", getChartName =
"GetChart.png";
+
+ public void generateChart() throws IOException
+ {
+ readData();
+
+ String putChartNameToUse = filenamePrefix == null ? putChartName : filenamePrefix +
"-" + putChartName;
+ File chartFile = new File(putChartNameToUse);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(putChartNameToUse + "." +
System.currentTimeMillis()));
+ chartFile = new File(putChartNameToUse);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart("Report: Comparing Cache
PUT (WRITE) performance", putData), 800, 800);
+
+ String getChartNameToUse = filenamePrefix == null ? getChartName : filenamePrefix +
"-" + getChartName;
+ chartFile = new File(getChartNameToUse);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(getChartNameToUse + "." +
System.currentTimeMillis()));
+ chartFile = new File(getChartNameToUse);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart("Report: Comparing Cache
GET (READ) performance", getData), 800, 800);
+
+ System.out.println("Charts saved as " + putChartNameToUse + " and
" + getChartNameToUse);
+ }
+
+ private JFreeChart createChart(String title, DefaultCategoryDataset data)
+ {
+ JFreeChart chart = ChartFactory.createBarChart3D(title, "Cache
operation", "Average time (�-seconds)", data, PlotOrientation.VERTICAL,
true, false, false);
+ BarRenderer3D renderer = (BarRenderer3D) chart.getCategoryPlot().getRenderer();
+ renderer.setBaseItemLabelsVisible(true);
+
+ final NumberFormat fmt = NumberFormat.getNumberInstance();
+ fmt.setMaximumFractionDigits(2);
+ fmt.setMinimumFractionDigits(2);
+
+ renderer.setBaseItemLabelGenerator(new CategoryItemLabelGenerator()
+ {
+
+ public String generateRowLabel(CategoryDataset categoryDataset, int i)
+ {
+ return null;
+ }
+
+ public String generateColumnLabel(CategoryDataset categoryDataset, int i)
+ {
+ return null;
+ }
+
+ public String generateLabel(CategoryDataset categoryDataset, int product, int
operation)
+ {
+ String retval;
+ try
+ {
+ retval = fmt.format(categoryDataset.getValue(product, operation)) + "
�s";
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ retval = e.toString();
+ }
+ return retval;
+ }
+ });
+
+ chart.addSubtitle(new TextTitle("Generated on " + new Date() + " by
The CacheBenchFwk"));
+ chart.setBorderVisible(true);
+ chart.setAntiAlias(true);
+ chart.setTextAntiAlias(true);
+ chart.setBackgroundPaint(new Color(0x61, 0x9e, 0xa1));
+ return chart;
+ }
+
+ 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");
+ }
+ });
+
+ putData = new DefaultCategoryDataset();
+ getData = new DefaultCategoryDataset();
+
+ for (File f : files)
+ {
+ readData(f);
+ }
+
+ //sort(averageThroughput);
+ }
+
+ private void readData(File f) throws IOException
+ {
+ String productName = f.getName();
+ if (productName.startsWith("data_"))
+ {
+ productName = productName.substring(5);
+ }
+
+ if (productName.indexOf(".xml") > 0)
+ {
+ productName = productName.substring(0, productName.indexOf(".xml"));
+ }
+
+ // now the contects of this file:
+
+ String line = null;
+ BufferedReader br = new BufferedReader(new FileReader(f));
+ double avgPut = -1, avgGet = -1;
+
+ while ((line = br.readLine()) != null && avgPut == -1 && avgGet ==
-1)
+ {
+ double[] tmp = getAveragePutAndGet(line);
+ avgPut = tmp[0];
+ avgGet = tmp[1];
+ }
+
+ br.close();
+
+ putData.addValue(avgPut, productName, "PUT");
+ getData.addValue(avgGet, productName, "GET");
+ }
+
+ private double[] getAveragePutAndGet(String line)
+ {
+ // To be a valid line, the line should be comma delimited
+ StringTokenizer strTokenizer = new StringTokenizer(line, ",");
+ if (strTokenizer.countTokens() < 7) return new double[]{-1, -1};
+
+ // 8th token is avg put
+ // 9th token is avg get
+ for (int i = 0; i < 7; i++) strTokenizer.nextToken();
+
+ String putStr = strTokenizer.nextToken();
+ String getStr = strTokenizer.nextToken();
+
+ double[] results = new double[2];
+ try
+ {
+ results[0] = Double.parseDouble(putStr) * 1000;
+ results[1] = Double.parseDouble(getStr) * 1000;
+ return results;
+ }
+ catch (NumberFormatException nfe)
+ {
+ return new double[]{-1, -1};
+ }
+ }
+
+}
Added:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java
(rev 0)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java 2008-05-12
16:18:11 UTC (rev 5828)
@@ -0,0 +1,183 @@
+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.chart.title.TextTitle;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import java.awt.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+/**
+ * Generates average and total throughput. Used for parsing reports generated with a
ClusterReportGenerator.
+ *
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ */
+public class ThroughputChartGenerator extends AbstractChartGen
+{
+ private DefaultCategoryDataset averageThroughput, totalThroughput;
+ private String chartNameAverage = "chart-averageThroughput.png",
chartNameTotal = "chart-totalThroughput.png";
+
+ public void generateChart() throws IOException
+ {
+ readData();
+
+ String chartAvgFileName = filenamePrefix == null ? chartNameAverage :
filenamePrefix + "-" + chartNameAverage;
+ File chartFile = new File(chartAvgFileName);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(chartAvgFileName + "." +
System.currentTimeMillis()));
+ chartFile = new File(chartAvgFileName);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart(averageThroughput,
"Report: Average throughput per cache instance", "Throughput per cache
instance (reqs/sec)"), 1024, 768);
+
+ String chartTotalFileName = filenamePrefix == null ? chartNameTotal :
filenamePrefix + "-" + chartNameTotal;
+ chartFile = new File(chartTotalFileName);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(chartTotalFileName + "." +
System.currentTimeMillis()));
+ chartFile = new File(chartTotalFileName);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart(totalThroughput, "Report:
Total throughput for cluster", "Overall throughput (reqs/sec)"), 1024,
768);
+
+ System.out.println("Charts saved as " + chartAvgFileName + " and
" + chartTotalFileName);
+ }
+
+ private JFreeChart createChart(CategoryDataset data, String title, String yLabel)
+ {
+ JFreeChart chart = ChartFactory.createLineChart(title, "Cluster size (number
of cache instances)", yLabel, data, PlotOrientation.VERTICAL, true, false, false);
+ chart.addSubtitle(new TextTitle("Generated on " + new Date() + " by
The CacheBenchFwk"));
+ chart.setBorderVisible(true);
+ chart.setAntiAlias(true);
+ chart.setTextAntiAlias(true);
+ chart.setBackgroundPaint(new Color(0x61, 0x9e, 0xa1));
+ return chart;
+ }
+
+ 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");
+ }
+ });
+
+ averageThroughput = new DefaultCategoryDataset();
+ totalThroughput = new DefaultCategoryDataset();
+ for (File f : files)
+ {
+ readData(f);
+ }
+
+ sort(averageThroughput);
+ sort(totalThroughput);
+ }
+
+ /**
+ * Crappy that the JFReechart data set doesn't order columns and rows by default
or even as an option. Need to do this manually.
+ *
+ * @param data
+ */
+ private void sort(DefaultCategoryDataset data)
+ {
+ SortedMap<Comparable, SortedMap<Comparable, Number>> raw = new
TreeMap<Comparable, SortedMap<Comparable, Number>>();
+ for (int i = 0; i < data.getRowCount(); i++)
+ {
+ Comparable row = data.getRowKey(i);
+ SortedMap<Comparable, Number> rowData = new TreeMap<Comparable,
Number>();
+ for (int j = 0; j < data.getColumnCount(); j++)
+ {
+ Comparable column = data.getColumnKey(j);
+ Number value = data.getValue(i, j);
+ rowData.put(column, value);
+ }
+ raw.put(row, rowData);
+ }
+
+ data.clear();
+ for (Comparable row : raw.keySet())
+ {
+ Map<Comparable, Number> rowData = raw.get(row);
+ for (Comparable column : rowData.keySet())
+ {
+ data.addValue(rowData.get(column), row, column);
+ }
+ }
+ }
+
+
+ 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);
+ }
+
+ averageThroughput.addValue(stats.getMean(), productNameAndConfiguration,
clusterSize);
+ totalThroughput.addValue(stats.getSum(), 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();
+ try
+ {
+ return Double.parseDouble(candidate);
+ }
+ catch (NumberFormatException nfe)
+ {
+ return -1;
+ }
+ }
+
+}