[jbosscache-commits] JBoss Cache SVN: r5794 - in benchmarks/benchmark-fwk/trunk: src/org/cachebench/reportgenerators and 6 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Fri May 2 08:54:47 EDT 2008
Author: mircea.markus
Date: 2008-05-02 08:54:47 -0400 (Fri, 02 May 2008)
New Revision: 5794
Added:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ConfigurationData.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportCentralizer.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportData.java
benchmarks/benchmark-fwk/trunk/tests/
benchmarks/benchmark-fwk/trunk/tests/org/
benchmarks/benchmark-fwk/trunk/tests/org/cachebench/
benchmarks/benchmark-fwk/trunk/tests/org/cachebench/reportgenerators/
benchmarks/benchmark-fwk/trunk/tests/org/cachebench/reportgenerators/reportcentralizer/
benchmarks/benchmark-fwk/trunk/tests/org/cachebench/reportgenerators/reportcentralizer/ReportDataTest.java
Modified:
benchmarks/benchmark-fwk/trunk/bindAddress.sh
benchmarks/benchmark-fwk/trunk/runNode.sh
Log:
added some additional report processing stuff
Modified: benchmarks/benchmark-fwk/trunk/bindAddress.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/bindAddress.sh 2008-05-02 10:36:40 UTC (rev 5793)
+++ benchmarks/benchmark-fwk/trunk/bindAddress.sh 2008-05-02 12:54:47 UTC (rev 5794)
@@ -1,5 +1,5 @@
#!/bin/sh
### Set your bind address for the tests to use. Could be an IP, host name or a reference to an environment variable.
-BIND_ADDRESS=${MYTESTIP_2}
+BIND_ADDRESS=127.0.0.1
Modified: benchmarks/benchmark-fwk/trunk/runNode.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/runNode.sh 2008-05-02 10:36:40 UTC (rev 5793)
+++ benchmarks/benchmark-fwk/trunk/runNode.sh 2008-05-02 12:54:47 UTC (rev 5794)
@@ -4,26 +4,13 @@
# those would make an automatic conversion from unix CLASSPATH to win classpath, needed when executing java -cp
preferIPv4Stack=true
-DEBUG=true
+DEBUG=debug
CURRENT_INDEX=${1}
CACHE_PRODUCT=${2}
TEST_CFG=${3}
CLUSTER_SIZE=${4}
-hostname=`hostname -s`
+hostname=`hostname`
PIDFILE=PID.${hostname}.pid
-if [ -e ${PIDFILE} ]
-then
- # first test if the process is still running. If not, clean up the PID file.
- pid=`cat ${PIDFILE}`
- if ps -C ${pid} > /dev/null
- then
- echo "A stale process already exists on this host! Run killNode.sh to kill it first."
- exit 3
- else
- ## This is a stale PID file. No such process is running.
- rm ${PIDFILE}
- fi
-fi
if [ -z $1 ]
then
@@ -60,8 +47,9 @@
fi
. ./bindAddress.sh
+echo bind address exit code is $?
-JVM_OPTIONS="${JVM_OPTIONS} -DcacheBenchFwk.cachePrioductName=${CACHE_PRODUCT} -Dbind.address=${BIND_ADDRESS} -DcacheBenchFwk.cacheConfigFile=${TEST_CFG} -DcurrentIndex=${CURRENT_INDEX} -DclusterSize=${CLUSTER_SIZE} -DcurrentIndex=${CURRENT_INDEX} -Djava.net.preferIPv4Stack=${preferIPv4Stack}"
+JVM_OPTIONS="${JVM_OPTIONS} -DcacheBenchFwk.cachePrioductName=${CACHE_PRODUCT} -Dbind.address=${BIND_ADDRESS} -DcacheBenchFwk.cacheConfigFile=${TEST_CFG} -DcurrentIndex=${CURRENT_INDEX} -DclusterSize=${CLUSTER_SIZE} -Djava.net.preferIPv4Stack=${preferIPv4Stack}"
TO_EXECUTE="java $JVM_OPTIONS -cp $CLASSPATH org.cachebench.CacheBenchmarkRunner"
if [ "$DEBUG" = "debug" ]
@@ -71,7 +59,7 @@
echo
fi
-${TO_EXECUTE} > STDIO_ERR.${hostname}.txt 2>&1 &
+${TO_EXECUTE}
echo $!>${PIDFILE}
echo "Return code from benchmark runner is $?"
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ConfigurationData.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ConfigurationData.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ConfigurationData.java 2008-05-02 12:54:47 UTC (rev 5794)
@@ -0,0 +1,53 @@
+package org.cachebench.reportgenerators.reportcentralizer;
+
+import java.util.*;
+
+/**
+ * Gathers the report data from all distributions that corespond to the same benchmark.
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+public class ConfigurationData {
+
+ private String configurationName;
+ private Set<String> distributions = new HashSet<String>();
+ private Map<String, List<ReportData>> distriution2ReportDataMap = new HashMap<String, List<ReportData>>();
+
+ public ConfigurationData(String configurationName) {
+ this.configurationName = configurationName;
+ }
+
+ public void addIfNeeded(ReportData reportData) {
+ if (reportData.getConfiguration().equals(configurationName)) {
+ String distribution = reportData.getDistribution();
+ distributions.add(distribution);
+ List<ReportData> dataList = distriution2ReportDataMap.get(distribution);
+ if (dataList == null) {
+ dataList = new ArrayList<ReportData>();
+ distriution2ReportDataMap.put(distribution, dataList);
+ }
+ dataList.add(reportData);
+ }
+ }
+
+ public Map<String, List<ReportData>> getDistriution2ReportDataMap() {
+ for (List<ReportData> datas : distriution2ReportDataMap.values()) {
+ Collections.sort(datas);
+ }
+ return distriution2ReportDataMap;
+ }
+
+ public String getConfigurationName() {
+ return configurationName;
+ }
+
+ public int[] getClusterSizes() {
+ String aDistribution = distributions.iterator().next();
+ List<ReportData> reportDatas = getDistriution2ReportDataMap().get(aDistribution);
+ int[] result = new int[reportDatas.size()];
+ for (int i = 0; i < reportDatas.size(); i++) {
+ result[i] = reportDatas.get(i).getClusterSize();
+ }
+ return result;
+ }
+}
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportCentralizer.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportCentralizer.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportCentralizer.java 2008-05-02 12:54:47 UTC (rev 5794)
@@ -0,0 +1,113 @@
+package org.cachebench.reportgenerators.reportcentralizer;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class ReportCentralizer {
+
+ public static final String SEPARATOR = ", ";
+
+ private String sourceReportDirectory;
+
+ private String destinationReportDirectory;
+
+
+ public ReportCentralizer(String reportsSourceDir, String reportsDestDir) throws Exception {
+ this.sourceReportDirectory = reportsSourceDir;
+ this.destinationReportDirectory = reportsDestDir;
+ process();
+ }
+
+ private void process() throws Exception {
+ File[] files = getReportFiles();
+ List<ReportData> reportDatas = parseFiles(files);
+ List<ConfigurationData> configurationDatas = buildBenchmarkData(reportDatas);
+ updateConfigurationDatas(reportDatas, configurationDatas);
+ generateReports(configurationDatas);
+ }
+
+ private void generateReports(List<ConfigurationData> configurationDatas) throws IOException {
+ File destDir = new File(destinationReportDirectory);
+ if (!destDir.exists()) {
+ destDir.mkdir();
+ }
+ for (ConfigurationData configData : configurationDatas) {
+ File reportFile = new File(destDir, configData.getConfigurationName() + ".csv");
+ reportFile.createNewFile();
+ PrintStream printStream = new PrintStream(reportFile);
+ writeHeader(printStream, configData.getClusterSizes());
+ Map<String,List<ReportData>> map = configData.getDistriution2ReportDataMap();
+ for (Map.Entry<String,List<ReportData>> entry : map.entrySet())
+ {
+ printProduct(printStream, entry);
+ }
+ printStream.flush();
+ printStream.close();
+ }
+ }
+
+ private void printProduct(PrintStream printStream, Map.Entry<String, List<ReportData>> entry) {
+ printStream.print(entry.getKey());
+ for (ReportData reportData: entry.getValue())
+ {
+ printStream.print(SEPARATOR + reportData.getAvgReqPerSec());
+ }
+ printStream.println();
+ }
+
+ private void writeHeader(PrintStream printStream, int[] clusterSizes) {
+ printStream.print("Cluster Size");
+ for (int i = 0; i < clusterSizes.length; i++) {
+ printStream.print(SEPARATOR + i);
+ }
+ printStream.println();
+ }
+
+ private void updateConfigurationDatas(List<ReportData> reportDatas, List<ConfigurationData> configurationDatas) {
+ for (ReportData data : reportDatas) {
+ for (ConfigurationData configurationData : configurationDatas) {
+ configurationData.addIfNeeded(data);
+ }
+ }
+ }
+
+ private List<ConfigurationData> buildBenchmarkData(List<ReportData> reportDatas) {
+ Set<String> alreadyProcessed = new HashSet<String>();
+ List<ConfigurationData> result = new ArrayList<ConfigurationData>();
+ for (ReportData reportData : reportDatas) {
+ if (!alreadyProcessed.contains(reportData.getConfiguration())) {
+ alreadyProcessed.add(reportData.getConfiguration());
+ result.add(new ConfigurationData(reportData.getConfiguration()));
+ }
+ }
+ return result;
+ }
+
+ private ArrayList<ReportData> parseFiles(File[] files) throws Exception {
+ ArrayList<ReportData> reportDatas = new ArrayList<ReportData>();
+ for (File file : files) {
+ reportDatas.add(new ReportData(file));
+ }
+ return reportDatas;
+ }
+
+ private File[] getReportFiles() {
+ File file = new File(sourceReportDirectory);
+ if (!file.exists() || !file.isDirectory())
+ throw new IllegalArgumentException("Report directory " + sourceReportDirectory + " does not exist or is not a directory!");
+ return file.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.toUpperCase().endsWith(".CSV");
+ }
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ String sourceDir = "c:\\temp\\centralizer\\in_real2";
+ String destDir = "c:\\temp\\centralizer\\in_real2\\centralized";
+ new ReportCentralizer(sourceDir, destDir);
+ }
+}
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportData.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportData.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/reportcentralizer/ReportData.java 2008-05-02 12:54:47 UTC (rev 5794)
@@ -0,0 +1,110 @@
+package org.cachebench.reportgenerators.reportcentralizer;
+
+import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.util.StringTokenizer;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class ReportData implements Comparable {
+
+ /**
+ * e.g. jbosscache-2.1.0
+ */
+ private String distribution;
+
+ /**
+ * e.g. pess-repl-async
+ */
+ private String configuration;
+ private int clusterSize;
+
+ private long avgReqPerSec;
+
+ public ReportData() {
+ }
+
+ public ReportData(File reportFile) throws Exception {
+ readData(reportFile);
+ }
+
+ private void readData(File f) throws IOException {
+ processFileName(f.getName());
+ // chop up the file name to get productAndConfiguration and clusterSize.
+ // file name is in the format data_<cache-product>_<cache-cfg.xml>_<cluster-size>.csv
+
+ // now read the data.
+ String line = null;
+ BufferedReader br = new BufferedReader(new FileReader(f));
+ int goodlinesCount = 0;
+ while ((line = br.readLine()) != null) {
+ double throughput = getThroughput(line);
+ if (throughput != -1) {
+ avgReqPerSec += throughput;
+ goodlinesCount++;
+ }
+ }
+ if (goodlinesCount < clusterSize)
+ {
+ throw new IllegalStateException("Number of line is not good for file: " + f.getName());
+ }
+ avgReqPerSec = avgReqPerSec / 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;
+ }
+ }
+
+
+ public String getDistribution() {
+ return distribution;
+ }
+
+ public String getConfiguration() {
+ return configuration;
+ }
+
+ public int getClusterSize() {
+ return clusterSize;
+ }
+
+ public long getAvgReqPerSec() {
+ return avgReqPerSec;
+ }
+
+ /* e.g. data_jbosscache-2.1.0_pess-repl-async.xml_2.csv */
+ public void processFileName(String name) {
+ StringTokenizer strtok = new StringTokenizer(name, "_");
+ strtok.nextToken(); // this is the "data-" bit
+ distribution = strtok.nextToken(); /* jbosscache-2.1.0 */
+ configuration = strtok.nextToken() /* pess-repl-async.xml */;
+ // cluster size
+ String cS = strtok.nextToken();
+ if (cS.toUpperCase().endsWith(".CSV")) cS = cS.substring(0, cS.length() - 4);
+ clusterSize = Integer.parseInt(cS);
+ }
+
+ public int compareTo(Object o) {
+ ReportData other = (ReportData) o;
+ return this.clusterSize - other.getClusterSize();
+ }
+}
Added: benchmarks/benchmark-fwk/trunk/tests/org/cachebench/reportgenerators/reportcentralizer/ReportDataTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/tests/org/cachebench/reportgenerators/reportcentralizer/ReportDataTest.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/tests/org/cachebench/reportgenerators/reportcentralizer/ReportDataTest.java 2008-05-02 12:54:47 UTC (rev 5794)
@@ -0,0 +1,26 @@
+package org.cachebench.reportgenerators.reportcentralizer;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test
+public class ReportDataTest {
+
+ /*
+ data_jbosscache-2.1.0_pess-repl-async.xml_2.csv
+ */
+ public void testParseFileName()
+ {
+ String filename = "data_jbosscache-2.1.0_pess-repl-async.xml_2.csv";
+ ReportData reportData = new ReportData();
+ reportData.processFileName(filename);
+ assert reportData.getClusterSize() == 2;
+ assert reportData.getConfiguration().equals("pess-repl-async.xml");
+ assert reportData.getDistribution().equals("jbosscache-2.1.0");
+ filename = "data_jbosscache-2.1.0_pess-repl-async.xml_22.csv";
+ reportData.processFileName(filename);
+ assert reportData.getClusterSize() == 22;
+ }
+}
More information about the jbosscache-commits
mailing list