Skip to content

Commit

Permalink
Use the same unit on bytes recording (opensource4you#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinghongfang authored Jul 28, 2022
1 parent f09b48a commit cb94360
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions app/src/main/java/org/astraea/app/performance/ReportFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.function.Supplier;
import java.util.stream.IntStream;
import org.astraea.app.common.DataSize;
import org.astraea.app.common.DataUnit;
import org.astraea.app.common.Utils;

public enum ReportFormat {
Expand Down Expand Up @@ -70,6 +71,7 @@ public static Runnable createFileWriter(
path.toString(),
"Performance"
+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
+ "."
+ reportFormat);
var writer = new BufferedWriter(new FileWriter(filePath.toFile()));
switch (reportFormat) {
Expand Down Expand Up @@ -108,7 +110,7 @@ public static Runnable createFileWriter(
private static void initCSVFormat(BufferedWriter writer, int producerCounts, int consumerCounts)
throws IOException {
writer.write(
"Time \\ Name, Consumed/Produced, Output throughput (/sec), Input throughput (/sec), "
"Time \\ Name, Consumed/Produced, Output throughput (MiB/sec), Input throughput (MiB/sec), "
+ "Publish max latency (ms), Publish min latency (ms), "
+ "End-to-end max latency (ms), End-to-end min latency (ms)");
IntStream.range(0, producerCounts)
Expand All @@ -118,9 +120,9 @@ private static void initCSVFormat(BufferedWriter writer, int producerCounts, int
writer.write(
",Producer["
+ i
+ "] current throughput (/sec), Producer["
+ "] current throughput (MiB/sec), Producer["
+ i
+ "] current publish latency (ms)");
+ "] average publish latency (ms)");
} catch (IOException ignore) {
}
});
Expand All @@ -131,9 +133,9 @@ private static void initCSVFormat(BufferedWriter writer, int producerCounts, int
writer.write(
",Consumer["
+ i
+ "] current throughput (/sec), Consumer["
+ "] current throughput (MiB/sec), Consumer["
+ i
+ "] current ene-to-end latency (ms)");
+ "] average ene-to-end latency (ms)");
} catch (IOException ignore) {
}
});
Expand All @@ -152,23 +154,38 @@ private static boolean logToCSV(
try {
writer.write(
result.duration.toHoursPart()
+ "h"
+ ":"
+ result.duration.toMinutesPart()
+ "m"
+ result.duration.toSecondsPart()
+ "s");
+ ":"
+ result.duration.toSecondsPart());
writer.write(
String.format(",%.2f%% / %.2f%%", result.consumerPercentage, result.producerPercentage));
writer.write("," + DataSize.Byte.of(result.producerResult.totalCurrentBytes()));
writer.write("," + DataSize.Byte.of(result.consumerResult.totalCurrentBytes()));
writer.write(
","
+ DataSize.Byte.of(result.producerResult.totalCurrentBytes())
.measurement(DataUnit.MiB)
.doubleValue());
writer.write(
","
+ DataSize.Byte.of(result.consumerResult.totalCurrentBytes())
.measurement(DataUnit.MiB)
.doubleValue());
writer.write("," + result.producerResult.maxLatency + "," + result.producerResult.minLatency);
writer.write("," + result.consumerResult.maxLatency + "," + result.consumerResult.minLatency);
for (int i = 0; i < result.producerResult.bytes.size(); ++i) {
writer.write("," + DataSize.Byte.of(result.producerResult.currentBytes.get(i)));
writer.write(
","
+ DataSize.Byte.of(result.producerResult.currentBytes.get(i))
.measurement(DataUnit.MiB)
.doubleValue());
writer.write("," + result.producerResult.averageLatencies.get(i));
}
for (int i = 0; i < result.consumerResult.bytes.size(); ++i) {
writer.write("," + DataSize.Byte.of(result.consumerResult.currentBytes.get(i)));
writer.write(
","
+ DataSize.Byte.of(result.consumerResult.currentBytes.get(i))
.measurement(DataUnit.MiB)
.doubleValue());
writer.write("," + result.consumerResult.averageLatencies.get(i));
}
writer.newLine();
Expand Down

0 comments on commit cb94360

Please sign in to comment.