/** * Main method for invoking benchs with classes as strings. * * @param args * the classes * @throws ClassNotFoundException * if class cannot be found * @throws IllegalAccessException * if conf cannot be instantiated * @throws InstantiationException * if conf cannot be instantiated */ public static void main(final String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException { final BenchmarkResult res = runBenchs(args); new TabularSummaryOutput().visitBenchmark(res); } }
/** * Adding an exception to this result. * * @param exec * the exception stored to this result */ public void addException(final AbstractPerfidixMethodException exec) { this.getExceptions().add(exec); for (final AbstractOutput output : outputs) { output.listenToException(exec); } }
/** * {@inheritDoc} */ @Override public boolean listenToResultSet(final Method meth, final AbstractMeter meter, final double data) { final PrintStream stream = setUpNewPrintStream(false, meth.getDeclaringClass().getSimpleName(), meth.getName(), meter .getName()); if (!firstResult) { stream.append(","); } stream.append(Double.toString(data)); stream.flush(); firstResult = false; return true; }
public void visitBenchmark(final BenchmarkResult benchRes) { final int numberOfColumns = 9; NiceTable table = new NiceTable(numberOfColumns); table = generateHeader(table); for (final AbstractMeter meter : benchRes.getRegisteredMeters()) { table.addHeader(meter.getName(), '=', Alignment.Center); for (final ClassResult classRes : benchRes.getIncludedResults()) { table.addHeader(classRes.getElementName(), '.', Alignment.Left); for (final MethodResult methRes : classRes.getIncludedResults()) { table = generateMeterResult(methRes.getElementName(), meter, methRes, table); table.addHeader(new StringBuilder("Summary for ").append(classRes.getElementName()) .toString(), '_', Alignment.Left); table = generateMeterResult("", meter, classRes, table); table.addLine('-'); table.addHeader("Summary for the whole benchmark", '=', Alignment.Center); table = generateMeterResult("", meter, benchRes, table); table.addHeader("Exceptions", '=', Alignment.Center); for (final AbstractPerfidixMethodException exec : benchRes.getExceptions()) { final StringBuilder execBuilder0 = new StringBuilder(); execBuilder0.append("Related exception: ").append(exec.getExec().getClass().getSimpleName()); table.addHeader(execBuilder0.toString(), ' ', Alignment.Left); table.addHeader(execBuilder1.toString(), ' ', Alignment.Left); if (exec.getMethod() != null) { final StringBuilder execBuilder2 = new StringBuilder();
/** * Test method for * {@link org.perfidix.ouput.TabularSummaryOutput#listenToException(org.perfidix.exceptions.AbstractPerfidixMethodException)} * . */ @Test public final void testListenToException() { final TabularSummaryOutput output = new TabularSummaryOutput(); output.listenToException(testException); final StringBuilder builder = new StringBuilder(); builder.append("Class: Class1#method1\n"); builder.append("Annotation: Bench\n"); builder.append("Exception: PerfidixMethodInvocationException/java.io.IOException\n"); builder.append("java.io.IOException\n"); assertTrue("Exception listener test", bytes.toString().startsWith(builder.toString())); }
benchRes.getIncludedResults().iterator().next().getIncludedResults().iterator().next(); final AbstractMeter meter = methRes.getRegisteredMeters().iterator().next(); final TabularSummaryOutput output = new TabularSummaryOutput(); for (final double d : methRes.getResultSet(meter)) { output.listenToResultSet((Method)methRes.getRelatedElement(), meter, d);
/** * Generating the results for a given table. * * @param columnDesc * the description for the row * @param meter * the corresponding {@link AbstractMeter} instance * @param result * the corresponding {@link AbstractResult} instance * @param input * the {@link NiceTable} to be print to * @return the modified {@link NiceTable} instance */ private NiceTable generateMeterResult(final String columnDesc, final AbstractMeter meter, final AbstractResult result, final NiceTable input) { input.addRow(new String[] { columnDesc, meter.getUnit(), AbstractOutput.format(result.sum(meter)), AbstractOutput.format(result.min(meter)), AbstractOutput.format(result.max(meter)), AbstractOutput.format(result.mean(meter)), AbstractOutput.format(result.getStandardDeviation(meter)), new StringBuilder("[").append(AbstractOutput.format(result.getConf05(meter))).append("-").append( AbstractOutput.format(result.getConf95(meter))).append("]").toString(), AbstractOutput.format(result.getResultSet(meter).size()) }); return input; }
/** * Test method for * {@link org.perfidix.ouput.CSVOutput#visitBenchmark(org.perfidix.result.BenchmarkResult)} . */ @Test public void testVisitListenSystemOut() { final CSVOutput output = new CSVOutput(); final ClassResult classRes = benchRes.getIncludedResults().iterator().next(); final AbstractMeter meter = classRes.getRegisteredMeters().iterator().next(); for (final MethodResult methRes : classRes.getIncludedResults()) { for (final double d : methRes.getResultSet(meter)) { output.listenToResultSet((Method)methRes.getRelatedElement(), meter, d); } } output.visitBenchmark(benchRes); assertTrue("first bunch of numbers must be in the test string", bytes.toString().contains( "0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0")); }
/** * Test method for * {@link org.perfidix.ouput.CSVOutput#listenToException(org.perfidix.exceptions.AbstractPerfidixMethodException)} * . */ @Test public void testListenExceptionSystemOut() { final CSVOutput output = new CSVOutput(); output.listenToException(testException); assertTrue("Testcase for exceptions", bytes.toString().startsWith( "Bench,Class1#method1,java.io.IOException")); }
/** * Test method for * {@link org.perfidix.ouput.CSVOutput#visitBenchmark(org.perfidix.result.BenchmarkResult)} . */ @Test public void testVisitSystemOut() { final CSVOutput output = new CSVOutput(); output.visitBenchmark(benchRes); final StringBuilder builderData1 = new StringBuilder(); builderData1.append("1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0"); assertTrue("first bunch of must be the same", bytes.toString().contains(builderData1.toString())); final StringBuilder builderData2 = new StringBuilder(); builderData2.append("0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0"); assertTrue("second bunch of must be the same", bytes.toString().contains(builderData2.toString())); final StringBuilder builderException = new StringBuilder(); builderException.append("Bench:Class1#method1\njava.io.IOException"); assertTrue("third bunch of must be the same", bytes.toString().contains(builderException.toString())); }
for (final AbstractMeter meter : methRes.getRegisteredMeters()) { final PrintStream currentWriter = setUpNewPrintStream(true, classRes.getElementName(), methRes.getElementName(), meter .getName()); boolean first = true; final PrintStream currentWriter = setUpNewPrintStream(true, "Exceptions"); tearDownAllStreams();
/** * Test method for * {@link org.perfidix.ouput.CSVOutput#listenToResultSet(java.lang.reflect.Method, org.perfidix.meter.AbstractMeter, double)} * . */ @Test public void testListenSystemOut() { final ClassResult classRes = benchRes.getIncludedResults().iterator().next(); final CSVOutput output = new CSVOutput(); final AbstractMeter meter = classRes.getRegisteredMeters().iterator().next(); for (final MethodResult methRes : classRes.getIncludedResults()) { for (final double d : methRes.getResultSet(meter)) { output.listenToResultSet((Method)methRes.getRelatedElement(), meter, d); } } final StringBuilder builderData1 = new StringBuilder(); builderData1.append("1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0"); assertTrue("first bunch of in the test string", bytes.toString().contains(builderData1.toString())); final StringBuilder builderData2 = new StringBuilder(); builderData2.append("0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0"); assertTrue("second bunch of in the test string", bytes.toString().contains(builderData2.toString())); }
final File toWriteTo = new File(folder, buildFileName(names)); try { if (usedFiles.containsKey(toWriteTo)) {
/** * Adding a dataset to a given meter and adapting the underlaying result * model. * * @param meth * where the result is corresponding to * @param meter * where the result is corresponding to * @param data * the data itself */ public void addData(final Method meth, final AbstractMeter meter, final double data) { final Class<?> clazz = meth.getDeclaringClass(); if (!elements.containsKey(clazz)) { elements.put(clazz, new ClassResult(clazz)); } final ClassResult clazzResult = elements.get(clazz); if (!clazzResult.elements.containsKey(meth)) { clazzResult.elements.put(meth, new MethodResult(meth)); } final MethodResult methodResult = clazzResult.elements.get(meth); methodResult.addData(meter, data); clazzResult.addData(meter, data); this.addData(meter, data); for (final AbstractOutput output : outputs) { output.listenToResultSet(meth, meter, data); } }
/** * This method starts the bench progress with the registered classes. * * @throws SocketViewException */ public boolean runBenchmark() throws SocketViewException { final BenchmarkResult res = benchmark.run(); new TabularSummaryOutput().visitBenchmark(res); view.finished(); return true; }
/** {@inheritDoc} */ @Override public boolean listenToException(final AbstractPerfidixMethodException exec) { final PrintStream currentWriter = setUpNewPrintStream(false, "Exceptions"); if (!firstException) { currentWriter.append("\n"); } currentWriter.append(exec.getRelatedAnno().getSimpleName()); currentWriter.append(","); if (exec.getMethod() != null) { currentWriter.append(exec.getMethod().getDeclaringClass().getSimpleName()); currentWriter.append("#"); currentWriter.append(exec.getMethod().getName()); currentWriter.append(","); } exec.getExec().printStackTrace(currentWriter); currentWriter.flush(); firstException = false; return true; }
/** * Simple setUp of a benchmark. The {@link Benchmark} is initialized with * two Meters (<code>TimeMeter</code> and <code>MemMeter</code>). Afterwards * the benchmark is running with a TabularOutput as a listener registered. * The result of the benchmark is displayed in a complete table at the end. * * @param args * not used here */ public static void main(String[] args) { final Benchmark bench = new Benchmark(new Config()); bench.add(ListBenchmark.class); final BenchmarkResult res = bench.run(); new TabularSummaryOutput().visitBenchmark(res); }
/** * Simple setUp of a benchmark. The {@link Benchmark} is initialized with * two Meters (<code>TimeMeter</code> and <code>MemMeter</code>). Afterwards * the benchmark is running with a TabularOutput as a listener registered. * The result of the benchmark is displayed in a complete table at the end. * * @param args * not used here */ public static void main(final String[] args) { final Benchmark bench = new Benchmark(new Config()); bench.add(StackBenchmark.class); final BenchmarkResult res = bench.run(); new TabularSummaryOutput().visitBenchmark(res); }
public static void main (String[] args) { Benchmark benchmark = new Benchmark(); benchmark.add(StorageBench.class); BenchmarkResult res = benchmark.run(); TabularSummaryOutput tab = new TabularSummaryOutput(); tab.visitBenchmark(res); }
final TabularSummaryOutput output = new TabularSummaryOutput(); output.visitBenchmark(benchRes); final StringBuilder builder = new StringBuilder(); builder