Skip to content

Commit 58f5abd

Browse files
authored
Merge pull request #7 from albertotn/master
added average time calculation with min and max
2 parents f0ca9f9 + c16e727 commit 58f5abd

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/main/java/AllocationCsvExporter.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,26 @@ private CSVFormat buildCsvFormat(String resultFilePath, int numberOfAllocations)
3838
}
3939

4040
private String[] buildCsvHeaders(int numberOfAllocations) {
41-
String[] csvHeaders = new String[(3 * numberOfAllocations) +5];
41+
String[] csvHeaders = new String[(3 * numberOfAllocations) +8];
4242
csvHeaders[0] = "Maven version";
4343
csvHeaders[1] = "Average (bytes)";
4444
csvHeaders[2] = "Average (Gb)";
4545
csvHeaders[3] = "Min (bytes)";
4646
csvHeaders[4] = "Max (bytes)";
47+
csvHeaders[5] = "Average length(seconds)";
48+
csvHeaders[6] = "Min length (seconds)";
49+
csvHeaders[7] = "Max length (seconds)";
4750

4851
for (int i = 1; i < numberOfAllocations + 1; i++) {
49-
csvHeaders[i + 4] = "Allocation" + " " + i + " "+ "(bytes)";
52+
csvHeaders[i + 7] = "Allocation" + " " + i + " "+ "(bytes)";
5053
}
5154

5255
for (int i = 1; i < numberOfAllocations + 1; i++) {
53-
csvHeaders[i + 4+ numberOfAllocations] = "Lenght" + " " + i + " "+ "(seconds)";
56+
csvHeaders[i + 7+ numberOfAllocations] = "Lenght" + " " + i + " "+ "(seconds)";
5457
}
5558

5659
for (int i = 1; i < numberOfAllocations + 1; i++) {
57-
csvHeaders[i + 4 + numberOfAllocations*2] = "Allocation" + " " + i + " "+ "(Gb)";
60+
csvHeaders[i + 7 + numberOfAllocations*2] = "Allocation" + " " + i + " "+ "(Gb)";
5861
}
5962
return csvHeaders;
6063
}
@@ -72,6 +75,12 @@ private List<Object> buildCsvRecord(Maven3Version maven3Version, AllocationTimeP
7275
csvRecord.add(allocationStatistics.getMin());
7376
csvRecord.add(allocationStatistics.getMax());
7477

78+
LongSummaryStatistics lengthStatistics = Arrays.stream(input).collect(Collectors.summarizingLong(AllocationTimePair::getLenghtInSeconds));
79+
double averageAllocationInSeconds = lengthStatistics.getAverage();
80+
csvRecord.add(averageAllocationInSeconds);
81+
csvRecord.add(lengthStatistics.getMin());
82+
csvRecord.add(lengthStatistics.getMax());
83+
7584
for (int i = 0; i < input.length; i++) {
7685
csvRecord.add(input[i].getAllocationInBytes());
7786
}
@@ -83,6 +92,8 @@ private List<Object> buildCsvRecord(Maven3Version maven3Version, AllocationTimeP
8392
for (int i = 0; i < input.length; i++) {
8493
csvRecord.add(input[i].getAllocationInBytes() / Math.pow(1024, 3));
8594
}
95+
96+
8697

8798
return csvRecord;
8899
}

0 commit comments

Comments
 (0)