-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New version 0.2.6 for csv report function
ENB-4946
- Loading branch information
Matthias Clasen
committed
Dec 7, 2020
1 parent
4256296
commit b533d9f
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/net/seibertmedia/jmeter/commands/ReportCSVCommandFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.seibertmedia.jmeter.commands; | ||
|
||
import static net.seibertmedia.jmeter.util.JMeterStatistic.Getter.median; | ||
import static net.seibertmedia.jmeter.util.StatisticsParser.createStatisticsFromFilename; | ||
|
||
import java.util.Map; | ||
|
||
import net.seibertmedia.jmeter.util.JMeterStatistics; | ||
import net.seibertmedia.jmeter.util.JMeterStatisticsCSVReport; | ||
|
||
public class ReportCSVCommandFunction implements AppCommandFunction { | ||
@Override | ||
public void apply(Map<String, String> args) throws Exception { | ||
JMeterStatistics elapsedStatistics = createStatisticsFromFilename(args.get("filename"), "elapsed"); | ||
JMeterStatisticsCSVReport jMeterStatisticsCSVReport = new JMeterStatisticsCSVReport(elapsedStatistics); | ||
|
||
jMeterStatisticsCSVReport.addValueColumn(median); | ||
|
||
jMeterStatisticsCSVReport.printReport(); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/net/seibertmedia/jmeter/util/JMeterStatisticsCSVReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.seibertmedia.jmeter.util; | ||
|
||
import java.io.PrintStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class JMeterStatisticsCSVReport { | ||
|
||
private final JMeterStatistics jMeterStatistics; | ||
private final List<JMeterStatistic.Getter> columns = new ArrayList<>(); | ||
|
||
public JMeterStatisticsCSVReport(JMeterStatistics jMeterStatistics) { | ||
this.jMeterStatistics = jMeterStatistics; | ||
} | ||
|
||
public void addValueColumn(JMeterStatistic.Getter columnGetter) { | ||
columns.add(columnGetter); | ||
} | ||
|
||
public void printReport() { | ||
printReport(System.out); | ||
} | ||
|
||
protected void printReport(PrintStream printStream) { | ||
|
||
for (String label : jMeterStatistics.getLabels()) { | ||
JMeterStatistic statisticsForLabel = jMeterStatistics.getStatisticForLabel(label); | ||
|
||
final Double[] values = columns.stream() | ||
.map(column -> column.getGetter().apply(statisticsForLabel)) | ||
.collect(Collectors.toList()).toArray(new Double[columns.size()]); | ||
|
||
printStream.print(label); | ||
printStream.printf(";%.0f\n", (Object[]) values); | ||
} | ||
} | ||
|
||
} |