private void runTest(AbstractTest test, String name, byte[] conf) { if (true) { // Create the repository directory File dir = new File(new File("target", "repository"), name + "-" + test); dir.mkdirs(); try { // Copy the configuration file into the repository directory File xml = new File(dir, "repository.xml"); OutputStream output = FileUtils.openOutputStream(xml); try { output.write(conf, 0, conf.length); } finally { output.close(); } // Create the repository RepositoryImpl repository = createRepository(dir, xml); try { // Run the test DescriptiveStatistics statistics = runTest(test, repository); if (statistics.getN() > 0) { writeReport(test.toString(), name, statistics); } } finally { repository.shutdown(); } } catch (Throwable t) { System.out.println("Unable to run " + test + ": " + t.getMessage()); t.printStackTrace(); } finally { // FileUtils.deleteQuietly(dir); } } }
@Override public String toString() { NumberFormat fmt = NumberFormat.getNumberInstance(); fmt.setMaximumFractionDigits(1); return description + ":" + " avg=" + fmt.format(stats.getMean()) + " stdev=" + fmt.format(stats.getStandardDeviation()) + " " + units + " (" + stats.getN() + " samples)"; }
@Override public String getSummaryReport() { final StringBuilder outBuffer = new StringBuilder(); final DescriptiveStatistics ds = computeStats(); outBuffer.append("Aggregate P@" + N + " Statistics:\n"); outBuffer.append(String.format("%-15s\t%6d\n", "num_q", ds.getN())); outBuffer.append(String.format("%-15s\t%6.4f\n", "min", ds.getMin())); outBuffer.append(String.format("%-15s\t%6.4f\n", "max", ds.getMax())); outBuffer.append(String.format("%-15s\t%6.4f\n", "mean", ds.getMean())); outBuffer.append(String.format("%-15s\t%6.4f\n", "std dev", ds.getStandardDeviation())); outBuffer.append(String.format("%-15s\t%6.4f\n", "median", ds.getPercentile(50))); outBuffer.append(String.format("%-15s\t%6.4f\n", "skewness", ds.getSkewness())); outBuffer.append(String.format("%-15s\t%6.4f\n", "kurtosis", ds.getKurtosis())); return outBuffer.toString(); }
@Override protected DescriptiveStatistics statistics( Collection<? extends Person> persons, String purpose, String mode) { DescriptiveStatistics stats = super.statistics(persons, purpose, mode); if (threshold > 0) { DescriptiveStatistics newStats = new DescriptiveStatistics(); for (int i = 0; i < stats.getN(); i++) { double val = stats.getElement(i); if (val >= threshold) { newStats.addValue(val); } } return newStats; } else { return stats; } }
/** * Get the count of points added to this series. * * @return count of points.s */ public long getCount() { return xData.getN(); }