Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ target
test-output
.idea
*.iml
/bin/
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#Perfidix - No discussions, Just facts.
[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/denisbenjamim/perfidix/blob/master/README.md)
[![pt-BR](https://img.shields.io/badge/lang-pt--BR-green.svg)](https://github.com/denisbenjamim/perfidix/blob/master/README.pt-BR.md)

# Perfidix - No discussions, Just facts.

Perfidix is a light-weight java library enabling users to benchmark sourcecode.
Similar to JUnit, annotations can be placed before methods.
Expand All @@ -7,7 +10,7 @@ An eclipse plugin (Perclipse, available under https://github.com/sebastiangraf/p

[![Build Status](https://secure.travis-ci.org/sebastiangraf/perfidix.png)](http://travis-ci.org/sebastiangraf/perfidix)

##5 steps how to use Perfidix
## 5 steps how to use Perfidix

* Get the lastest jar over Github or Maven

Expand All @@ -31,18 +34,18 @@ OR

For further documentation and as an example, please refer to the `org.perfidix.example` package.

##Content
## Content

* README: this readme file
* LICENSE: license file
* src: Source folder for perfidix itself
* pom.xml: Simple pom (yes we use Maven)

##License
## License

This work is released in the public domain under the BSD 3-clause license

##Further information
## Further information

The documentation so far is accessible under http://perfidix.org (pointing to http://sebastiangraf.github.com/perfidix/).

Expand All @@ -51,7 +54,7 @@ The framework was presented at the Jazoon '07 as work in progress. The paper can

Any questions, just contact sebastian.graf AT uni-konstanz.de

##Involved People
## Involved People

Perfidix is maintained by:

Expand Down
71 changes: 71 additions & 0 deletions README.pt-BR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/denisbenjamim/perfidix/blob/master/README.md)

# Perfidix - Sem discussões, apenas fatos.

Perfidix é uma biblioteca java leve que permite aos usuários avaliar o código fonte.
Semelhante ao JUnit, as anotações podem ser colocadas antes dos métodos.
Dentro da invocação desses métodos, medições flexíveis são executadas.
Um plugin do eclipse (Perclipse, disponível em https://github.com/sebastiangraf/perclipse ) oferece fácil uso de qualquer método anotado.

[![Build Status](https://secure.travis-ci.org/sebastiangraf/perfidix.png)](http://travis-ci.org/sebastiangraf/perfidix)

## 5 etapas para usar o Perfidix

* Pegue o último jar no Github ou Maven

```xml
<dependency>
<groupId>org.perfidix</groupId>
<artifactId>perfidix</artifactId>
<version>4.0.0</version>
</dependency>
```

* Anote seus métodos de bancada `@Bench`. Nota-se que estes métodos têm de ter o seguinte assinatura: `public (final) void method()`.
* Crie um novo objecto do tipo `Benchmark`.
* Adicione a classe com os métodos anotados desta forma `benchmarkObj.add(MyBenchmarkTest.class)`.
* Obtenha o `BenchmarkResult` com `benchmarkObj.run()`.
* Exiba o resultado desta forma `new TabularSummaryOutput (). VisitBenchmark (benchmarkResultObj)`.

OU

* Instale o plug-in Perclipse no site (http://sebastiangraf.github.com/perclipse/) e execute "Executar como" (consulte o Perclipse-Readme para obter mais informações: https://github.com/sebastiangraf/perclipse ).

Para obter mais documentação e exemplo, consulte o pacote `org.perfidix.example`.

## Conteúdo

* README: arquivo leia-me original
* README.pt-BR: este arquivo leia-me
* LICENSE: arquivo de licença
* src: pasta de origem para o próprio perfidix
* pom.xml: pom simples (sim, usamos Maven)

## Licença

Este trabalho foi lançado em domínio público sob a licença BSD de 3 cláusulas

## Outras informações

A documentação até agora está acessível em http://perfidix.org (apontando para http://sebastiangraf.github.com/perfidix/ ).

A estrutura foi apresentada no Jazoon '07 como um trabalho em andamento. O jornal pode ser encontrado [aqui](http://nbn-resolving.de/urn:nbn:de:bsz:352-opus-84446).

Qualquer dúvida, basta entrar em contato com sebastian.graf AT uni-konstanz.de

## Pessoas Envolvidas

Perfidix é mantido por:

* Sebastian Graf (núcleo da Perfidix e líder de Projeto)

Os subprojetos concluídos foram:

* [Nico Haase](mailto:[email protected]) (benchmarks parametrizados)
* Nuray Gürler (Mocking e Maven-Website)
* Bastian Lemke (saída do gráfico)
* Alexander Onea (primeiro lançamento do núcleo)
* Tim Petrowski (primeiro lançamento do núcleo)
* Marc Kramis (líder de projeto até 2007)


4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<site.deploy.dir>/tmp/deploy</site.deploy.dir>
</properties>
</project>
61 changes: 40 additions & 21 deletions src/main/java/org/perfidix/ouput/TabularSummaryOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
package org.perfidix.ouput;


import java.io.PrintStream;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

import org.perfidix.element.BenchmarkMethod;
import org.perfidix.exceptions.AbstractPerfidixMethodException;
import org.perfidix.exceptions.PerfidixMethodInvocationException;
Expand All @@ -30,9 +36,6 @@
import org.perfidix.result.ClassResult;
import org.perfidix.result.MethodResult;

import java.io.PrintStream;
import java.lang.reflect.Method;


/**
* Summary output using the {@link NiceTable} to format. Just giving an overview of statistical analysis over the
Expand All @@ -41,7 +44,9 @@
* @author Sebastian Graf, University of Konstanz
*/
public final class TabularSummaryOutput extends AbstractOutput {

private final String LINE_SEPARATOR;

private final ResourceBundle BUNDLE;
/**
* Print stream where the result should end.
*/
Expand All @@ -55,6 +60,8 @@ public final class TabularSummaryOutput extends AbstractOutput {
public TabularSummaryOutput(final PrintStream paramOut) {
super();
out = paramOut;
BUNDLE = ResourceBundle.getBundle("messages", Locale.getDefault());
LINE_SEPARATOR = System.lineSeparator();
}

/**
Expand All @@ -80,38 +87,38 @@ public void visitBenchmark(final BenchmarkResult benchRes) {
table = generateMeterResult(methRes.getElementName(), meter, methRes, table);
}

table.addHeader(new StringBuilder("Summary for ").append(classRes.getElementName()).toString(), '_', Alignment.Left);
table.addHeader(new StringBuilder(getMessageI18n("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.addHeader(getMessageI18n("summary"), '=', Alignment.Center);

for (final AbstractMeter meter : benchRes.getRegisteredMeters()) {
table = generateMeterResult("", meter, benchRes, table);
}

table.addHeader("Exceptions", '=', Alignment.Center);
table.addHeader(getMessageI18n("exceptions"), '=', Alignment.Center);
for (final AbstractPerfidixMethodException exec : benchRes.getExceptions()) {
final StringBuilder execBuilder0 = new StringBuilder();
execBuilder0.append("Related exception: ").append(exec.getExec().getClass().getSimpleName());
execBuilder0.append(getMessageI18n("related.exceptions")).append(exec.getExec().getClass().getSimpleName());
table.addHeader(execBuilder0.toString(), ' ', Alignment.Left);

final StringBuilder execBuilder1 = new StringBuilder();
if (exec instanceof PerfidixMethodInvocationException) {
execBuilder1.append("Related place: method invocation");
execBuilder1.append(getMessageI18n("related.place", "method.invocation"));
} else {
execBuilder1.append("Related place: method check");
execBuilder1.append(getMessageI18n("related.place", "method.check"));
}
table.addHeader(execBuilder1.toString(), ' ', Alignment.Left);
if (exec.getMethod() != null) {
final StringBuilder execBuilder2 = new StringBuilder();
execBuilder2.append("Related method: ").append(exec.getMethod().getName());
execBuilder2.append(getMessageI18n("related.method")).append(exec.getMethod().getName());
table.addHeader(execBuilder2.toString(), ' ', Alignment.Left);
}
final StringBuilder execBuilder3 = new StringBuilder();
execBuilder3.append("Related annotation: ").append(exec.getRelatedAnno().getSimpleName());
execBuilder3.append(getMessageI18n("related.annotation")).append(exec.getRelatedAnno().getSimpleName());
table.addHeader(execBuilder3.toString(), ' ', Alignment.Left);
table.addLine('-');

Expand Down Expand Up @@ -141,10 +148,11 @@ private NiceTable generateMeterResult(final String columnDesc, final AbstractMet
public boolean listenToResultSet(final BenchmarkMethod meth, final AbstractMeter meter, final double data) {
Method m = meth.getMethodToBench();
final StringBuilder builder = new StringBuilder();
builder.append("Class: ").append(m.getDeclaringClass().getSimpleName()).append("#").append(m.getName());
builder.append("\nMeter: ").append(meter.getName());
builder.append("\nData: ").append(data).append("\n");
out.println(builder.toString());

builder.append(MessageFormat.format("Class: {1}#{2}{0}", LINE_SEPARATOR, m.getDeclaringClass().getSimpleName(), m.getName()));
builder.append(MessageFormat.format("Meter: {1}{0}", LINE_SEPARATOR, meter.getName()));
builder.append(MessageFormat.format("Data: {1}{0}", LINE_SEPARATOR, String.valueOf(data)));
out.println(builder.toString());
return true;
}

Expand All @@ -155,10 +163,10 @@ public boolean listenToResultSet(final BenchmarkMethod meth, final AbstractMeter
public boolean listenToException(final AbstractPerfidixMethodException exec) {
final StringBuilder builder = new StringBuilder();
if (exec.getMethod() != null) {
builder.append("Class: ").append(exec.getMethod().getDeclaringClass().getSimpleName()).append("#").append(exec.getMethod().getName()).append("\n");
builder.append("Class: ").append(exec.getMethod().getDeclaringClass().getSimpleName()).append("#").append(exec.getMethod().getName()).append(LINE_SEPARATOR);
}
builder.append("Annotation: ").append(exec.getRelatedAnno().getSimpleName());
builder.append("\nException: ").append(exec.getClass().getSimpleName()).append("/").append(exec.getExec().toString());
builder.append("Annotation: ").append(exec.getRelatedAnno().getSimpleName()).append(LINE_SEPARATOR);
builder.append("Exception: ").append(exec.getClass().getSimpleName()).append("/").append(exec.getExec().toString());
out.println(builder.toString());
exec.getExec().printStackTrace(out);
return true;
Expand All @@ -172,9 +180,20 @@ public boolean listenToException(final AbstractPerfidixMethodException exec) {
* @return another {@link NiceTable} instance
*/
private NiceTable generateHeader(final NiceTable table) {
table.addHeader("Benchmark");
table.addRow(new String[]{"-", "unit", "sum", "min", "max", "avg", "stddev", "conf95", "runs"});
table.addHeader(getMessageI18n("benchmark"));
table.addRow(new String[]{"-", getMessageI18n("unit"), getMessageI18n("sum"), getMessageI18n("min"), getMessageI18n("max"), getMessageI18n("avg"), getMessageI18n("stddev"), getMessageI18n("conf95"), getMessageI18n("runs")});
return table;
}

private String getMessageI18n(String key) {
return BUNDLE.getString(MessageFormat.format("tabularSummaryOutput.{0}", key));
}

private String getMessageI18n(String key1, String key2) {
String message = BUNDLE.getString(MessageFormat.format("tabularSummaryOutput.{0}", key1));
String message2 = BUNDLE.getString(MessageFormat.format("tabularSummaryOutput.{0}", key2));

return MessageFormat.format("{0} {1}", message, message2);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class AbstractTabularComponent {
/**
* Constant for the newline-symbol.
*/
static final String NEWLINE = "\n";
static final String NEWLINE = System.lineSeparator();

/**
* Border symbol, can be changed in the runtime.
Expand Down
15 changes: 4 additions & 11 deletions src/main/java/org/perfidix/ouput/asciitable/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static String repeat(final String toBeRepeated, final int numTimes) {
* @return an array of elements
*/
private static String[] explode(final String toBeSplitted) {
return toBeSplitted.split("\\" + '\n');
return toBeSplitted.split(AbstractTabularComponent.NEWLINE);
}

/**
Expand All @@ -148,14 +148,7 @@ private static String[] explode(final String toBeSplitted) {
* @return the number of occurences of {@link org.perfidix.ouput.asciitable.AbstractTabularComponent#NEWLINE} in the string.
*/
private static int numNewLines(final String toExamine) {
final char[] arr = toExamine.toCharArray();
int result = 0;
for (char ch : arr) {
if (AbstractTabularComponent.NEWLINE.equals(new String(new char[]{ch}))) {
result++;
}
}
return result;
return toExamine.split(AbstractTabularComponent.NEWLINE).length;
}

/**
Expand All @@ -180,10 +173,10 @@ public static String[][] createMatrix(final String[] data) {
for (final String col : data) {
maxNewLines = Math.max(maxNewLines, Util.numNewLines(col));
}
final String[][] matrix = new String[maxNewLines + 1][data.length];
final String[][] matrix = new String[maxNewLines][data.length];
for (int col = 0; col < data.length; col++) {
final String[] exploded = Util.explode(data[col]);
for (int row = 0; row < maxNewLines + 1; row++) {
for (int row = 0; row < maxNewLines; row++) {
if (exploded.length > row) {
matrix[row][col] = exploded[row];
} else {
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tabularSummaryOutput.benchmark = Benchmark
tabularSummaryOutput.unit = unit
tabularSummaryOutput.sum = sum
tabularSummaryOutput.min = min
tabularSummaryOutput.max = max
tabularSummaryOutput.avg = avg
tabularSummaryOutput.stddev = stddev
tabularSummaryOutput.conf95 = conf95
tabularSummaryOutput.runs = runs
tabularSummaryOutput.summary.for = Summary for
tabularSummaryOutput.summary = Summary for the whole benchmark
tabularSummaryOutput.exceptions = Exceptions
tabularSummaryOutput.related.exceptions = Related exception:
tabularSummaryOutput.related.place = Related place:
tabularSummaryOutput.related.method = Related method:
tabularSummaryOutput.related.annotation = Related annotation:
tabularSummaryOutput.method.invocation = method invocation
tabularSummaryOutput.method.check = method check
18 changes: 18 additions & 0 deletions src/main/resources/messages_pt_BR.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tabularSummaryOutput.benchmark = Benchmark
tabularSummaryOutput.unit = unidade
tabularSummaryOutput.sum = soma
tabularSummaryOutput.min = minimo
tabularSummaryOutput.max = maximo
tabularSummaryOutput.avg = m�dia
tabularSummaryOutput.stddev = saida console
tabularSummaryOutput.conf95 = conf95
tabularSummaryOutput.runs = execu��es
tabularSummaryOutput.summary.for = Resumo para
tabularSummaryOutput.summary = Resumo de todo benchmark
tabularSummaryOutput.exceptions = Exce��es
tabularSummaryOutput.related.exceptions = Exce��o relacionada:
tabularSummaryOutput.related.place = Lugar relacionado:
tabularSummaryOutput.related.method = M�todo relacionado:
tabularSummaryOutput.related.annotation = Anota��o relacionada:
tabularSummaryOutput.method.invocation = invoca��o de m�todo
tabularSummaryOutput.method.check = verifica��o de m�todo
Loading