Author: ivo...@gmail.com Date: Fri May 4 15:27:48 2012 New Revision: 2312 Log: [AMDATUAUTH-123] More checkstyle fixes
Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/Utils.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/FrequencyDiagram.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterPlanReport.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterResultsParser.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ReportSummary.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/Statistics.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/XYSample.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ZSamples.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/main/Main.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/ApplicationContext.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/Logger.java trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/TestContext.java Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/Utils.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/Utils.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/Utils.java Fri May 4 15:27:48 2012 @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.amdatu.auth.test.performance.analyzer; - +package org.amdatu.auth.test.performance.analyzer; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; @@ -24,79 +24,88 @@ import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; - -public class Utils { - // Private constant for buffer size. - private static final int BUFFER_SIZE = 40 * 1024; // Blocks of 40 Kb each - - /** - * Unzips the file to the specified target directory. - * @param zipFile The zipfile to unzip - * @param targetDir The directory in which the resulting files should be Stored - * @exception IOException If not all files could be saved - */ - public static void unzip(File zipFile, File targetDir) throws IOException { - // Create the buffer for streaming the contents - - // Create the zip input stream - ZipInputStream zip = null; - try { - zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile), BUFFER_SIZE)); - // Process each entry - ZipEntry entry; - while ((entry = zip.getNextEntry()) != null) { - // Get and normalize the path - String path = entry.getName(); - path = path.replace('/', File.separatorChar); - path = path.replace('\\', File.separatorChar); - File target = new File(targetDir, path); - // Check whether the target is a file or directory - if (entry.isDirectory()) { - target.mkdirs(); - } else { - writeZipEntryToFile(zip, target); - } - - // Set the last modified to the date specified in the zip - long time = entry.getTime(); - if (time != -1) { - target.setLastModified(time); - } - } - } finally { - if (zip != null) { - zip.close(); - } - } - } - - /** - * Writes the content of the zip entry to the specified file. - * @param zip The zip entry to write - * @param target The file to write to - * @throws IOException In case a IO exception occurs - */ - public static void writeZipEntryToFile(ZipInputStream zip, File target) throws IOException { - // Create the parent directory - File parent = target.getParentFile(); - if (!parent.exists()) { - parent.mkdirs(); - } - // Stream the contents to the target file - int bytes; - byte[] buffer = new byte[BUFFER_SIZE]; - OutputStream out = null; - try { - out = new BufferedOutputStream(new FileOutputStream(target), BUFFER_SIZE); - while ((bytes = zip.read(buffer, 0, buffer.length)) != -1) { - out.write(buffer, 0, bytes); - } - } catch (IOException ex) { - throw ex; - } finally { - if (out != null) { - out.close(); - } - } - } -} + +public final class Utils { + // Private constant for buffer size. + private static final int BUFFER_SIZE = 40 * 1024; // Blocks of 40 Kb each + + private Utils() { + } + + /** + * Unzips the file to the specified target directory. + * + * @param zipFile The zipfile to unzip + * @param targetDir The directory in which the resulting files should be Stored + * @exception IOException If not all files could be saved + */ + public static void unzip(File zipFile, File targetDir) throws IOException { + // Create the buffer for streaming the contents + + // Create the zip input stream + ZipInputStream zip = null; + try { + zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile), BUFFER_SIZE)); + // Process each entry + ZipEntry entry; + while ((entry = zip.getNextEntry()) != null) { + // Get and normalize the path + String path = entry.getName(); + path = path.replace('/', File.separatorChar); + path = path.replace('\\', File.separatorChar); + File target = new File(targetDir, path); + // Check whether the target is a file or directory + if (entry.isDirectory()) { + target.mkdirs(); + } + else { + writeZipEntryToFile(zip, target); + } + + // Set the last modified to the date specified in the zip + long time = entry.getTime(); + if (time != -1) { + target.setLastModified(time); + } + } + } + finally { + if (zip != null) { + zip.close(); + } + } + } + + /** + * Writes the content of the zip entry to the specified file. + * + * @param zip The zip entry to write + * @param target The file to write to + * @throws IOException In case a IO exception occurs + */ + public static void writeZipEntryToFile(ZipInputStream zip, File target) throws IOException { + // Create the parent directory + File parent = target.getParentFile(); + if (!parent.exists()) { + parent.mkdirs(); + } + // Stream the contents to the target file + int bytes; + byte[] buffer = new byte[BUFFER_SIZE]; + OutputStream out = null; + try { + out = new BufferedOutputStream(new FileOutputStream(target), BUFFER_SIZE); + while ((bytes = zip.read(buffer, 0, buffer.length)) != -1) { + out.write(buffer, 0, bytes); + } + } + catch (IOException ex) { + throw ex; + } + finally { + if (out != null) { + out.close(); + } + } + } +} Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/FrequencyDiagram.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/FrequencyDiagram.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/FrequencyDiagram.java Fri May 4 15:27:48 2012 @@ -15,9 +15,13 @@ */ package org.amdatu.auth.test.performance.analyzer.analysis; +import java.text.DecimalFormat; import java.util.List; +import org.apache.commons.math3.distribution.NormalDistribution; import org.apache.commons.math3.stat.Frequency; +import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; +import org.apache.commons.math3.stat.inference.TestUtils; public class FrequencyDiagram { private static final String EOL = System.getProperty("line.separator"); @@ -25,25 +29,31 @@ private double m_min = Double.MAX_VALUE; private double m_max = Double.MIN_VALUE; + private double m_mean = 0; + private double m_sd = 0; private Frequency m_frequency; private String m_name; - - + public FrequencyDiagram(String name) { m_name = name; } public void generate(List<Double> values) { m_frequency = new Frequency(); + double sum = 0; for (Double value : values) { m_min = Math.min(m_min, value); m_max = Math.max(m_max, value); m_frequency.addValue(value); + sum += value; + } + m_mean = sum / values.size(); + double[] dValues = new double[values.size()]; + for (int i = 0; i < values.size(); i++) { + dValues[i] = values.get(i); } + m_sd = new StandardDeviation().evaluate(dValues); } - - - private String getFrequencies() { // Split the values from min to max into 100 pieces and plot @@ -51,8 +61,8 @@ double interval = (m_max - m_min) / INTERVALS; for (int i = 1; i <= INTERVALS; i++) { double from = m_min + i * interval; - double to = m_min + (i+1) * interval; - String value = new Long(m_frequency.getCumFreq(to)-m_frequency.getCumFreq(from)).toString(); + double to = m_min + (i + 1) * interval; + String value = new Long(m_frequency.getCumFreq(to) - m_frequency.getCumFreq(from)).toString(); if (frequencies == null) { frequencies = "['" + shorten(from) + "', " + value + "]"; } @@ -62,18 +72,41 @@ } return "[" + frequencies + "]"; } - + + public double getGoodnessOfFit() { + long[] observed = new long[INTERVALS]; + double[] expected = new double[INTERVALS]; + double interval = (m_max - m_min) / INTERVALS; + NormalDistribution nd = new NormalDistribution(m_mean, m_sd); + for (int i = 1; i <= INTERVALS; i++) { + // First calculate the observed frequency + double from = m_min + i * interval; + double to = m_min + (i + 1) * interval; + observed[i - 1] = new Long(m_frequency.getCumFreq(to) - m_frequency.getCumFreq(from)); + + // Calculate the expected frequency, under the assumption that it is normally + // distributed + expected[i - 1] = nd.cumulativeProbability(from, to) * m_frequency.getSumFreq(); + } + + // Now perform a Chi-Square test for the null hypotheses that Z is normally distributed + // with given mean and sd + return 100 * (1 - TestUtils.chiSquareTest(expected, observed)); + } + private String shorten(double number) { String sign = number < 0 ? "-" : ""; number = Math.abs(number); String result; if (number >= 10) { result = new Long(Math.round(number)).toString(); - } else if (number < 10 && number >= 1) { - result = new Long(Math.round(10*number)).toString(); + } + else if (number < 10 && number >= 1) { + result = new Long(Math.round(10 * number)).toString(); result = result.charAt(0) + "." + result.charAt(1); - } else { - result = new Long(Math.round(10*number)).toString(); + } + else { + result = new Long(Math.round(10 * number)).toString(); result = "0." + result.charAt(0); } return sign + result; Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterPlanReport.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterPlanReport.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterPlanReport.java Fri May 4 15:27:48 2012 @@ -46,7 +46,7 @@ } /** - * Throughput can only be calculates over all samples in a single report + * Throughput can only be calculates over all samples in a single report. */ public void setThroughput(double x, double y) { m_throughputX = x; @@ -54,7 +54,7 @@ } /** - * Duration + * Duration. */ public void setDuration(double x, double y) { m_durationX = x; Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterResultsParser.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterResultsParser.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/JMeterResultsParser.java Fri May 4 15:27:48 2012 @@ -13,92 +13,94 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.amdatu.auth.test.performance.analyzer.analysis; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * Parses the results of a JMeter execution - * @author <a href="mailto:amdatu-develop...@amdatu.org">Amdatu Project Team</a> - * - */ -public class JMeterResultsParser extends DefaultHandler { - // Name of the JMeter plan - private String m_jmeterPlanName; - private String m_version; - - private Map<String, List<XYSample>> m_results = new HashMap<String, List<XYSample>>(); - - private double m_sampleCount; - private long m_tsMin = System.currentTimeMillis(); - private long m_tsMax = 0; - - private long start = -1; - private long end = -1; - - public JMeterResultsParser(String name) { - m_jmeterPlanName = name; - } - - public String getName() { - return m_jmeterPlanName; - } - - public String getVersion() { - return m_version != null ? m_version : "unknown"; - } - - public double getThroughput() { - long diff = m_tsMax - m_tsMin; - double throughput = m_sampleCount/(diff/1000.0); - return throughput; - } - - public double getDuration() { - return (end - start)/1000.0; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("httpSample".equals(qName)) { - String stepName = attributes.getValue("lb"); - boolean success = "true".equalsIgnoreCase(attributes.getValue("s")); - long timeStamp = Long.parseLong(attributes.getValue("ts")); - m_tsMin = Math.min(m_tsMin, timeStamp); - m_tsMax = Math.max(m_tsMax, timeStamp); - int responseTime = Integer.parseInt(attributes.getValue("t")); - m_sampleCount++; - - XYSample result = new XYSample(); - result.stepName = stepName; - result.responseTime = responseTime; - result.timeStamp = timeStamp; - result.success = success; - - if (start == -1 || timeStamp < start) { - start = timeStamp; - } - if (end == -1 || timeStamp > end) { - end = timeStamp; - } - - if (!m_results.containsKey(stepName)) { - m_results.put(stepName, new ArrayList<XYSample>()); - } - m_results.get(stepName).add(result); - } else if ("testResults".equals(qName)) { - m_version = attributes.getValue("amdatuversion"); - } - } - - public Map<String, List<XYSample>> getResults() { - return m_results; - } -} +package org.amdatu.auth.test.performance.analyzer.analysis; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * Parses the results of a JMeter execution. + * + * @author <a href="mailto:amdatu-develop...@amdatu.org">Amdatu Project Team</a> + * + */ +public class JMeterResultsParser extends DefaultHandler { + // Name of the JMeter plan + private String m_jmeterPlanName; + private String m_version; + + private Map<String, List<XYSample>> m_results = new HashMap<String, List<XYSample>>(); + + private double m_sampleCount; + private long m_tsMin = System.currentTimeMillis(); + private long m_tsMax = 0; + + private long m_start = -1; + private long m_end = -1; + + public JMeterResultsParser(String name) { + m_jmeterPlanName = name; + } + + public String getName() { + return m_jmeterPlanName; + } + + public String getVersion() { + return m_version != null ? m_version : "unknown"; + } + + public double getThroughput() { + long diff = m_tsMax - m_tsMin; + double throughput = m_sampleCount / (diff / 1000.0); + return throughput; + } + + public double getDuration() { + return (m_end - m_start) / 1000.0; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if ("httpSample".equals(qName)) { + String stepName = attributes.getValue("lb"); + boolean success = "true".equalsIgnoreCase(attributes.getValue("s")); + long timeStamp = Long.parseLong(attributes.getValue("ts")); + m_tsMin = Math.min(m_tsMin, timeStamp); + m_tsMax = Math.max(m_tsMax, timeStamp); + int responseTime = Integer.parseInt(attributes.getValue("t")); + m_sampleCount++; + + XYSample result = new XYSample(); + result.stepName = stepName; + result.responseTime = responseTime; + result.timeStamp = timeStamp; + result.success = success; + + if (m_start == -1 || timeStamp < m_start) { + m_start = timeStamp; + } + if (m_end == -1 || timeStamp > m_end) { + m_end = timeStamp; + } + + if (!m_results.containsKey(stepName)) { + m_results.put(stepName, new ArrayList<XYSample>()); + } + m_results.get(stepName).add(result); + } + else if ("testResults".equals(qName)) { + m_version = attributes.getValue("amdatuversion"); + } + } + + public Map<String, List<XYSample>> getResults() { + return m_results; + } +} Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ReportSummary.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ReportSummary.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ReportSummary.java Fri May 4 15:27:48 2012 @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; -import java.net.URISyntaxException; import java.net.URL; import java.text.DecimalFormat; import java.util.ArrayList; @@ -152,222 +151,253 @@ } table.append("</tr>"); - // Mean of X - table.append("<tr><td>M<sub>x</sub></td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.sampleMeanX.isNaN()) { - table.append(reallyBad("-")); - } - else { - table.append("<td>" + round(sample.sampleMeanX) + "</td>"); - } - } - table.append("</tr>"); - - // Minimum of X - table.append("<tr><td>Min<sub>x</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.minX) + "</td>"); - } - table.append("</tr>"); + // X stats + appendXStats(table, report); - // Maximum of X - table.append("<tr><td>Max<sub>x</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.maxX) + "</td>"); - } - table.append("</tr>"); + // Y stats + appendYStats(table, report); - // Median of X - table.append("<tr><td>Median<sub>x</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.medianX) + "</td>"); - } - table.append("</tr>"); + // Z stats + appendZStats(table, report); - // Wald-Wolfowitz probability of X - table.append("<tr><td>Wald-Wolfowitz<sub>x</sub></td>"); + // Success rate X + table.append("<tr><td>Success rate X</td>"); for (ZSamples sample : report.getSamples()) { - if (sample.waldWolfowitzX < 0.01) { - table.append(bad(round(100 * sample.waldWolfowitzX) + "%")); + if (sample.successRateX != 1) { + table.append(reallyBad(round(100 * sample.successRateX) + "%")); } else { - table.append("<td>" + round(100 * sample.waldWolfowitzX) + "%</td>"); + table.append("<td>" + round(100 * sample.successRateX) + "%</td>"); } } table.append("</tr>"); - // Mean of Y - table.append("<tr><td>M<sub>y</sub></td>"); + // Success rate Y + table.append("<tr><td>Success rate Y</td>"); for (ZSamples sample : report.getSamples()) { - if (sample.sampleMeanY.isNaN()) { - table.append(reallyBad("-")); + if (sample.successRateY != 1) { + table.append(reallyBad(round(100 * sample.successRateY) + "%")); } else { - table.append("<td>" + round(sample.sampleMeanY) + "</td>"); + table.append("<td>" + round(100 * sample.successRateY) + "%</td>"); } } table.append("</tr>"); + table.append("</table>"); + } + return table.toString(); + } - // Minimum of Y - table.append("<tr><td>Min<sub>y</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.minY) + "</td>"); + private void appendXStats(StringBuffer table, JMeterPlanReport report) { + // Mean of X + table.append("<tr><td>M<sub>x</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.sampleMeanX.isNaN()) { + table.append(reallyBad("-")); } - table.append("</tr>"); - - // Maximum of Y - table.append("<tr><td>Max<sub>y</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.maxY) + "</td>"); + else { + table.append("<td>" + round(sample.sampleMeanX) + "</td>"); } - table.append("</tr>"); + } + table.append("</tr>"); - // Median of Y - table.append("<tr><td>Median<sub>y</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.medianY) + "</td>"); - } - table.append("</tr>"); + // Minimum of X + table.append("<tr><td>Min<sub>x</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.minX) + "</td>"); + } + table.append("</tr>"); - // Wald-Wolfowitz probability of X - table.append("<tr><td>Wald-Wolfowitz<sub>y</sub></td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.waldWolfowitzY < 0.01) { - table.append(bad(round(100 * sample.waldWolfowitzY) + "%")); - } - else { - table.append("<td>" + round(100 * sample.waldWolfowitzY) + "%</td>"); - } - } - table.append("</tr>"); + // Maximum of X + table.append("<tr><td>Max<sub>x</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.maxX) + "</td>"); + } + table.append("</tr>"); - // Mean of Z - table.append("<tr><td>M<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.sampleMean) + "</td>"); - } - table.append("</tr>"); + // Median of X + table.append("<tr><td>Median<sub>x</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.medianX) + "</td>"); + } + table.append("</tr>"); - // Standard deviation of Z - table.append("<tr><td>S<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.sampleSD) + "</td>"); + // Wald-Wolfowitz probability of X + table.append("<tr><td>Wald-Wolfowitz<sub>x</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.waldWolfowitzX < 0.01) { + table.append(bad(round(100 * sample.waldWolfowitzX) + "%")); } - table.append("</tr>"); - - // Median of Z - table.append("<tr><td>Median<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.medianZ) + "</td>"); + else { + table.append("<td>" + round(100 * sample.waldWolfowitzX) + "%</td>"); } - table.append("</tr>"); + } + table.append("</tr>"); + } - // Wald-Wolfowitz probability of Z - table.append("<tr><td>Wald-Wolfowitz<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.waldWolfowitzZ.isNaN()) { - table.append(reallyBad("-")); - } - else if (sample.waldWolfowitzZ < 0.01) { - table.append(bad(round(100 * sample.waldWolfowitzZ) + "%")); - } - else { - table.append("<td>" + round(100 * sample.waldWolfowitzZ) + "%</td>"); - } + private void appendYStats(StringBuffer table, JMeterPlanReport report) { + // Mean of Y + table.append("<tr><td>M<sub>y</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.sampleMeanY.isNaN()) { + table.append(reallyBad("-")); } - table.append("</tr>"); - - // t-value of Z - table.append("<tr><td>t<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.t) + "</td>"); + else { + table.append("<td>" + round(sample.sampleMeanY) + "</td>"); } - table.append("</tr>"); + } + table.append("</tr>"); - // Probability of t-value - table.append("<tr><td>Pt<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + round(sample.p) + "</td>"); - } - table.append("</tr>"); + // Minimum of Y + table.append("<tr><td>Min<sub>y</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.minY) + "</td>"); + } + table.append("</tr>"); - // [power] difference between X and Y - table.append("<tr><td>D<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.D.isNaN()) { - table.append("<td>-</td>"); - } - else if (sample.D < 0) { - table.append(good(round(sample.D))); - } - else { - table.append(bad(round(sample.D))); - } - } - table.append("</tr>"); + // Maximum of Y + table.append("<tr><td>Max<sub>y</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.maxY) + "</td>"); + } + table.append("</tr>"); - // Percentile [power] difference between X and Y - table.append("<tr><td>Δ<sub>z</sub></td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.delta.isNaN()) { - table.append("<td>-</td>"); - } - else if (sample.delta < -0.05) { - table.append(reallyGood(round(100 * sample.delta) + "%")); - } - else if (sample.delta <= 0) { - table.append(good(round(100 * sample.delta) + "%")); - } - else if (sample.delta < 0.05) { - table.append(bad(round(100 * sample.delta) + "%")); - } - else { - table.append(reallyBad(round(100 * sample.delta) + "%")); - } + // Median of Y + table.append("<tr><td>Median<sub>y</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.medianY) + "</td>"); + } + table.append("</tr>"); + + // Wald-Wolfowitz probability of Y + table.append("<tr><td>Wald-Wolfowitz<sub>y</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.waldWolfowitzY < 0.01) { + table.append(bad(round(100 * sample.waldWolfowitzY) + "%")); } - table.append("</tr>"); + else { + table.append("<td>" + round(100 * sample.waldWolfowitzY) + "%</td>"); + } + } + table.append("</tr>"); + } - // H0 hypothesis - table.append("<tr><td>H<sub>0</sub></td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + (sample.H0 ? "accepted" : "rejected") + "</td>"); + private void appendZStats(StringBuffer table, JMeterPlanReport report) { + // Mean of Z + table.append("<tr><td>M<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.sampleMean) + "</td>"); + } + table.append("</tr>"); + + // Standard deviation of Z + table.append("<tr><td>S<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.sampleSD) + "</td>"); + } + table.append("</tr>"); + + // Median of Z + table.append("<tr><td>Median<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.medianZ) + "</td>"); + } + table.append("</tr>"); + + // Wald-Wolfowitz probability of Z + table.append("<tr><td>Wald-Wolfowitz<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.waldWolfowitzZ.isNaN()) { + table.append(reallyBad("-")); } - table.append("</tr>"); + else if (sample.waldWolfowitzZ < 0.01) { + table.append(bad(round(100 * sample.waldWolfowitzZ) + "%")); + } + else { + table.append("<td>" + round(100 * sample.waldWolfowitzZ) + "%</td>"); + } + } + table.append("</tr>"); - // H0 hypothesis power - table.append("<tr><td>H<sub>0</sub> power</td>"); - for (ZSamples sample : report.getSamples()) { - table.append("<td>" + sample.power + "</td>"); + // Chi Square probability of Z + table.append("<tr><td>Chi Square<sub>z</sub></td>"); + for (FrequencyDiagram fd : report.getFrequencyDiagrams()) { + double gof = fd.getGoodnessOfFit(); + if (gof < 1) { + table.append(reallyBad(round(gof) + "%")); } - table.append("</tr>"); + else if (gof < 5) { + table.append(bad(round(gof) + "%")); + } + else { + table.append("<td>" + round(gof) + "%</td>"); + } + } + table.append("</tr>"); - // Success rate X - table.append("<tr><td>Success rate X</td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.successRateX != 1) { - table.append(reallyBad(round(100 * sample.successRateX) + "%")); - } - else { - table.append("<td>" + round(100 * sample.successRateX) + "%</td>"); - } + // t-value of Z + table.append("<tr><td>t<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.t) + "</td>"); + } + table.append("</tr>"); + + // Probability of t-value + table.append("<tr><td>Pt<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + round(sample.p) + "</td>"); + } + table.append("</tr>"); + + // [power] difference between X and Y + table.append("<tr><td>D<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.D.isNaN()) { + table.append("<td>-</td>"); } - table.append("</tr>"); + else if (sample.D < 0) { + table.append(good(round(sample.D))); + } + else { + table.append(bad(round(sample.D))); + } + } + table.append("</tr>"); - // Success rate Y - table.append("<tr><td>Success rate Y</td>"); - for (ZSamples sample : report.getSamples()) { - if (sample.successRateY != 1) { - table.append(reallyBad(round(100 * sample.successRateY) + "%")); - } - else { - table.append("<td>" + round(100 * sample.successRateY) + "%</td>"); - } + // Percentile [power] difference between X and Y + table.append("<tr><td>Δ<sub>z</sub></td>"); + for (ZSamples sample : report.getSamples()) { + if (sample.delta.isNaN()) { + table.append("<td>-</td>"); + } + else if (sample.delta < -0.05) { + table.append(reallyGood(round(100 * sample.delta) + "%")); + } + else if (sample.delta <= 0) { + table.append(good(round(100 * sample.delta) + "%")); + } + else if (sample.delta < 0.05) { + table.append(bad(round(100 * sample.delta) + "%")); + } + else { + table.append(reallyBad(round(100 * sample.delta) + "%")); } - table.append("</tr>"); - table.append("</table>"); } - return table.toString(); + table.append("</tr>"); + + // H0 hypothesis + table.append("<tr><td>H<sub>0</sub></td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + (sample.H0 ? "accepted" : "rejected") + "</td>"); + } + table.append("</tr>"); + + // H0 hypothesis power + table.append("<tr><td>H<sub>0</sub> power</td>"); + for (ZSamples sample : report.getSamples()) { + table.append("<td>" + sample.power + "</td>"); + } + table.append("</tr>"); } private StringBuffer getFrequencyGraphsJQuery() { Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/Statistics.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/Statistics.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/Statistics.java Fri May 4 15:27:48 2012 @@ -22,7 +22,6 @@ import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; @@ -37,16 +36,14 @@ * This class analyzes the results of JMeter plans executed against version X and Y. It assumes that Z=X-Y is * normally distributed, and under this assumption we test the null hypotheses mean(Z) = 0. Under this assumption, * T=mean(Z)sqrt(n)/S has a T distribution with (n-1) degrees of freedom. - * TODO: Note that the assumption that Z is normally distributed is very likely, but it remains an assumption. To - * verify the distribution, we should perform a goodness of fit check; room for improvement. - * + * * @author <a href="mailto:amdatu-develop...@amdatu.org">Amdatu Project Team</a> */ public class Statistics { - public final static String SAMPLES = "_samples."; - public final static String SAMPLES_X = SAMPLES + "X"; - public final static String SAMPLES_Y = SAMPLES + "Y"; - + public static final String SAMPLES = "_samples."; + public static final String SAMPLES_X = SAMPLES + "X"; + public static final String SAMPLES_Y = SAMPLES + "Y"; + private ApplicationContext m_context; private List<ReportSummary> m_reports = new ArrayList<ReportSummary>(); @@ -66,7 +63,7 @@ File reportY = new File(sample + "Y"); String reportName = reportX.getName().substring(0, reportX.getName().length() - SAMPLES_X.length()); - + Logger.log("Parsing samples..."); SAXParser sax = SAXParserFactory.newInstance().newSAXParser(); JMeterResultsParser resultsX = new JMeterResultsParser(reportName); @@ -106,7 +103,8 @@ String path = file.getParent(); String fileName = file.getName().substring(0, file.getName().indexOf(SAMPLES_X)); samples.add(path + File.separator + fileName + SAMPLES); - } else if (file.getAbsolutePath().endsWith(".zip")) { + } + else if (file.getAbsolutePath().endsWith(".zip")) { zippedResultDir = file; } } Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/XYSample.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/XYSample.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/XYSample.java Fri May 4 15:27:48 2012 @@ -20,9 +20,11 @@ * * @author <a href="mailto:amdatu-develop...@amdatu.org">Amdatu Project Team</a> */ -public class XYSample { +public class XYSample { + // @checkstyle:off String stepName; // Name of the sample, i.e. 'Open dashboard' int responseTime; // Response time long timeStamp; // Timestamp, used for throughput calculation - boolean success; // Success indication + boolean success; // Success indication + // @checkstyle:on } Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ZSamples.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ZSamples.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/analysis/ZSamples.java Fri May 4 15:27:48 2012 @@ -29,6 +29,7 @@ import org.apache.commons.math.distribution.NormalDistributionImpl; import org.apache.commons.math.distribution.TDistributionImpl; import org.apache.commons.math.stat.descriptive.rank.Median; +import org.apache.commons.math3.stat.inference.TestUtils; /** * This class holds the samples of the sample observations (Z0=X0-Y0), (Z1=X1-Y1), ..., (Zn=Xn-Yn). @@ -267,16 +268,16 @@ private double getWaldWolfowitzProbability(double[] values) throws MathException { List<Integer> signs = new ArrayList<Integer>(); - double Nplus = 0, Nmin = 0; + double nPlus = 0, nMin = 0; double median = new Median().evaluate(values); for (int i = 0; i < values.length; i++) { if (values[i] < median) { signs.add(new Integer(-1)); - Nmin++; + nMin++; } else if (values[i] > median) { signs.add(new Integer(+1)); - Nplus++; + nPlus++; } } @@ -291,9 +292,9 @@ // Now R should be normally distributed under the null hypothesis of randomness // with mean and variance: - double N = Nmin + Nplus; - double meanR = (2 * Nmin * Nplus) / N + 1; - double varR = ((meanR - 1) * (meanR - 2)) / (N - 1); + double n = nMin + nPlus; + double meanR = (2 * nMin * nPlus) / n + 1; + double varR = ((meanR - 1) * (meanR - 2)) / (n - 1); // Now calculate the probability of our outcome or runs under the null hypothesis if (varR == 0) { Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/main/Main.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/main/Main.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/main/Main.java Fri May 4 15:27:48 2012 @@ -33,36 +33,39 @@ * * @author <a href="mailto:amdatu-develop...@amdatu.org">Amdatu Project Team</a> */ -public class Main { +public final class Main { public static String CONFIGFILE_ARG = "-config"; public static String VERBOSE_ARG = "-verbose"; public static String RESULTSDIR_ARG = "-resultsdir"; public static String SAMPLESIZE_ARG = "-m"; // Wordy arguments - private final static List<String> BOOLEAN_ARGS = new ArrayList<String>(); + private static final List<String> BOOLEAN_ARGS = new ArrayList<String>(); static { BOOLEAN_ARGS.add(VERBOSE_ARG); } // File arguments - private final static List<String> FILE_ARGS = new ArrayList<String>(); + private static final List<String> FILE_ARGS = new ArrayList<String>(); static { FILE_ARGS.add(CONFIGFILE_ARG); } // Directory arguments - private final static List<String> DIR_ARGS = new ArrayList<String>(); + private static final List<String> DIR_ARGS = new ArrayList<String>(); static { DIR_ARGS.add(RESULTSDIR_ARG); } // Other arguments - private final static List<String> OTHER_ARGS = new ArrayList<String>(); + private static final List<String> OTHER_ARGS = new ArrayList<String>(); static { OTHER_ARGS.add(SAMPLESIZE_ARG); } + private Main() { + } + public static void main(String[] args) { try { int i = 0; Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/ApplicationContext.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/ApplicationContext.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/ApplicationContext.java Fri May 4 15:27:48 2012 @@ -13,51 +13,55 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.amdatu.auth.test.performance.analyzer.runtest; - +package org.amdatu.auth.test.performance.analyzer.runtest; + import org.amdatu.auth.test.performance.analyzer.main.Main; import java.io.IOException; import java.util.Map; - -public class ApplicationContext { - public String resultsDir; // directory to write results to - public int sampleSize = -1; - - public final static String VERSION_X = "X"; - public final static String VERSION_Y = "Y"; - - public TestContext contextX; - public TestContext contextY; - public String currentContextName; - public TestContext currentContext; - - public ApplicationContext(Map<String, Object> arguments) throws IOException { - resultsDir = arguments.get(Main.RESULTSDIR_ARG).toString(); - if (arguments.containsKey(Main.SAMPLESIZE_ARG)) { - sampleSize = Integer.parseInt(arguments.get(Main.SAMPLESIZE_ARG).toString()); - } - } - - public void setContext(TestContext x, TestContext y) { - contextX = x; - contextY = y; - } - - public void setCurrentContext(String current) { - currentContextName = current; - if (current.equals(VERSION_X)) { - currentContext = contextX; - } else { - currentContext = contextY; - } - } - - public String getVersionVsVersion() { - return contextX.version + "-vs-" + contextY.version; - } - - public String getSamplesPostFix() { - return "_" + contextX.version + "-vs-" + contextY.version + "_samples"; - } -} + +public class ApplicationContext { + // @checkstyle:off + public String resultsDir; // directory to write results to + public int sampleSize = -1; + + public final static String VERSION_X = "X"; + public final static String VERSION_Y = "Y"; + + public TestContext contextX; + public TestContext contextY; + public String currentContextName; + public TestContext currentContext; + + // @checkstyle:on + + public ApplicationContext(Map<String, Object> arguments) throws IOException { + resultsDir = arguments.get(Main.RESULTSDIR_ARG).toString(); + if (arguments.containsKey(Main.SAMPLESIZE_ARG)) { + sampleSize = Integer.parseInt(arguments.get(Main.SAMPLESIZE_ARG).toString()); + } + } + + public void setContext(TestContext x, TestContext y) { + contextX = x; + contextY = y; + } + + public void setCurrentContext(String current) { + currentContextName = current; + if (current.equals(VERSION_X)) { + currentContext = contextX; + } + else { + currentContext = contextY; + } + } + + public String getVersionVsVersion() { + return contextX.version + "-vs-" + contextY.version; + } + + public String getSamplesPostFix() { + return "_" + contextX.version + "-vs-" + contextY.version + "_samples"; + } +} Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/Logger.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/Logger.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/Logger.java Fri May 4 15:27:48 2012 @@ -20,18 +20,21 @@ import java.io.IOException; import java.util.Calendar; -public class Logger { - public static FileWriter logFile; +public final class Logger { + public static FileWriter LOGFILE; + + private Logger() { + } public static void setLogFile(String dir) throws IOException { File f = new File(dir + File.separator + "perftest-" + getTimestamp() + ".log"); f.createNewFile(); - logFile = new FileWriter(dir + File.separator + "perftest-" + getTimestamp() + ".log"); + LOGFILE = new FileWriter(dir + File.separator + "perftest-" + getTimestamp() + ".log"); } public static void closeLogFile() throws IOException { - if (logFile != null) { - logFile.close(); + if (LOGFILE != null) { + LOGFILE.close(); } } @@ -58,7 +61,7 @@ public static void log(String message) { System.out.println(message); try { - logFile.append(message + System.getProperty("line.separator")); + LOGFILE.append(message + System.getProperty("line.separator")); } catch (IOException e) { e.printStackTrace(); Modified: trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/TestContext.java ============================================================================== --- trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/TestContext.java (original) +++ trunk/amdatu-auth/test-performance/test-analyzer/src/main/java/org/amdatu/auth/test/performance/analyzer/runtest/TestContext.java Fri May 4 15:27:48 2012 @@ -18,8 +18,10 @@ import java.io.File; public class TestContext { + // @checkstyle:off public String version; public String binFile; + // @checkstyle:on public TestContext(File zipFile) { binFile = zipFile.getAbsolutePath(); @@ -111,7 +113,8 @@ else { if (rc1 < rc2) { return -1; - } else if (rc1 > rc2) { + } + else if (rc1 > rc2) { return +1; } return 0; _______________________________________________ Amdatu-commits mailing list Amdatu-commits@amdatu.org http://lists.amdatu.org/mailman/listinfo/amdatu-commits