MINOR: fix integer overflow in simple benchmark MB/sec calculation
Author: Damian Guy
Reviewers: Ismael Juma
Closes from dguy/minor-streams-bench
@@ -334,7 +334,7 @@ public class SimpleBenchmark {
processedRecords + "/" +
latency + "/" +
recordsPerSec(latency, processedRecords) + "/" +
- megaBytePerSec(latency, processedRecords, RECORD_SIZE));
+ megabytesPerSec(latency, processedRecords, RECORD_SIZE));
}
private void runGenericBenchmark(final KafkaStreams streams, final String nameOfBenchmark, final CountDownLatch latch) {
@@ -488,7 +488,7 @@ public class SimpleBenchmark {
numRecords + "/" +
(endTime - startTime) + "/" +
recordsPerSec(endTime - startTime, numRecords) + "/" +
- megaBytePerSec(endTime - startTime, numRecords, KEY_SIZE + valueSizeBytes));
+ megabytesPerSec(endTime - startTime, numRecords, KEY_SIZE + valueSizeBytes));
}
}
@@ -536,7 +536,7 @@ public class SimpleBenchmark {
consumedRecords + "/" +
(endTime - startTime) + "/" +
recordsPerSec(endTime - startTime, consumedRecords) + "/" +
- megaBytePerSec(endTime - startTime, consumedRecords, RECORD_SIZE));
+ megabytesPerSec(endTime - startTime, consumedRecords, RECORD_SIZE));
}
private KafkaStreams createKafkaStreams(String topic, final CountDownLatch latch) {
@@ -716,8 +716,8 @@ public class SimpleBenchmark {
}
- private double megaBytePerSec(long time, int numRecords, int recordSizeBytes) {
- return (double) (recordSizeBytes * numRecords / 1024 / 1024) / ((double) time / 1000);
+ private double megabytesPerSec(long time, int numRecords, int recordSizeBytes) {
+ return ((double) recordSizeBytes * numRecords / 1024 / 1024) / (time / 1000.0);
}
private double recordsPerSec(long time, int numRecords) {
