Author: manik.surtani(a)jboss.com
Date: 2008-01-30 21:21:20 -0500 (Wed, 30 Jan 2008)
New Revision: 5276
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
Log:
better graphs
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java 2008-01-31
01:53:26 UTC (rev 5275)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java 2008-01-31
02:21:20 UTC (rev 5276)
@@ -5,14 +5,17 @@
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.title.DateTitle;
+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.StringTokenizer;
/**
@@ -33,8 +36,8 @@
{
static String reportDirectory;
static boolean singleChart = true;
- DefaultCategoryDataset dataset;
- static String chartName = "chart.png";
+ DefaultCategoryDataset averageThroughput, totalThroughput;
+ static String chartNameAverage = "chart-averageThroughput.png",
chartNameTotal = "chart-totalThroughput.png";
private static void help()
@@ -74,26 +77,43 @@
if (!singleChart) throw new RuntimeException("Multiple charts not yet
implemented");
new ChartGenerator().generateChart();
- System.out.println("Finished in " + ((System.currentTimeMillis() -
startTime) / 1000) + " seconds! Chart saved as " + chartName);
+ System.out.println("Finished in " + ((System.currentTimeMillis() -
startTime) / 1000) + " seconds! Charts saved as " + chartNameAverage + "
and " + chartNameTotal);
}
private void generateChart() throws IOException
{
readData();
- JFreeChart chart = ChartFactory.createLineChart("CacheBenchFwk Report",
"Cluster size", "Throughput (reqs/sec)",
- dataset, PlotOrientation.VERTICAL, true, false, false);
- chart.addSubtitle(new DateTitle());
- File chartFile = new File(chartName);
+ File chartFile = new File(chartNameAverage);
if (chartFile.exists())
{
- chartFile.renameTo(new File(chartName + "." +
System.currentTimeMillis()));
- chartFile = new File(chartName);
+ chartFile.renameTo(new File(chartNameAverage + "." +
System.currentTimeMillis()));
+ chartFile = new File(chartNameAverage);
}
- ChartUtilities.saveChartAsPNG(chartFile, chart, 600, 800);
+ ChartUtilities.saveChartAsPNG(chartFile, createChart(averageThroughput,
"Report: Average throughput per cache instance", "Throughput per cache
instance (reqs/sec)"), 1024, 768);
+
+ chartFile = new File(chartNameTotal);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(chartNameTotal + "." +
System.currentTimeMillis()));
+ chartFile = new File(chartNameTotal);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart(totalThroughput, "Report:
Total throughput for cluster", "Overall throughput (reqs/sec)"), 1024,
768);
}
+ 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);
@@ -108,7 +128,8 @@
}
});
- dataset = new DefaultCategoryDataset();
+ averageThroughput = new DefaultCategoryDataset();
+ totalThroughput = new DefaultCategoryDataset();
for (File f : files)
{
readData(f);
@@ -144,7 +165,8 @@
if (throughput != -1) stats.addValue(throughput);
}
- dataset.addValue(stats.getMean(), productNameAndConfiguration, clusterSize);
+ averageThroughput.addValue(stats.getMean(), productNameAndConfiguration,
clusterSize);
+ totalThroughput.addValue(stats.getSum(), productNameAndConfiguration,
clusterSize);
}
private double getThroughput(String line)