Skip to content

Commit

Permalink
[testclient] Add total messages when printing throughput (apache#12084)
Browse files Browse the repository at this point in the history
### Motivation
Add total read/produce messages when periodic printing throughput in `PerformanceReader` / `ManagedLedgerWriter`&`PerformanceClient`

### Modifications
- Get `totalMessages` then add it to the log information
  • Loading branch information
yuruguo authored Sep 28, 2021
1 parent 0460472 commit 91697c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,17 @@ public void runPerformanceTest(long messages, long limit, int numOfTopic, int si
long now = System.nanoTime();
double elapsed = (now - oldTime) / 1e9;

long total = totalMessagesSent.sum();
double rate = messagesSent.sumThenReset() / elapsed;
double throughput = bytesSent.sumThenReset() / elapsed / 1024 / 1024 * 8;

reportHistogram = SimpleTestProducerSocket.recorder.getIntervalHistogram(reportHistogram);

log.info(
"Throughput produced: {} msg/s --- {} Mbit/s --- Latency: mean: {} ms - med: {} ms - 95pct: {} ms - 99pct: {} ms - 99.9pct: {} ms - 99.99pct: {} ms",
throughputFormat.format(rate), throughputFormat.format(throughput),
"Throughput produced: {} msg --- {} msg/s --- {} Mbit/s --- Latency: mean: {} ms - med: {} ms - 95pct: {} ms - 99pct: {} ms - 99.9pct: {} ms - 99.99pct: {} ms",
intFormat.format(total),
throughputFormat.format(rate),
throughputFormat.format(throughput),
dec.format(reportHistogram.getMean() / 1000.0),
dec.format(reportHistogram.getValueAtPercentile(50) / 1000.0),
dec.format(reportHistogram.getValueAtPercentile(95) / 1000.0),
Expand Down Expand Up @@ -384,6 +387,7 @@ private static void printAggregatedStats() {
static final DecimalFormat throughputFormat = new PaddingDecimalFormat("0.0", 8);
static final DecimalFormat dec = new PaddingDecimalFormat("0.000", 7);
static final DecimalFormat totalFormat = new DecimalFormat("0.000");
static final DecimalFormat intFormat = new PaddingDecimalFormat("0", 7);
private static final Logger log = LoggerFactory.getLogger(PerformanceClient.class);

}
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,17 @@ public void addFailed(ManagedLedgerException exception, Object ctx) {
long now = System.nanoTime();
double elapsed = (now - oldTime) / 1e9;

long total = totalMessagesSent.sum();
double rate = messagesSent.sumThenReset() / elapsed;
double throughput = bytesSent.sumThenReset() / elapsed / 1024 / 1024 * 8;

reportHistogram = recorder.getIntervalHistogram(reportHistogram);

log.info(
"Throughput produced: {} msg/s --- {} Mbit/s --- Latency: mean: {} ms - med: {} - 95pct: {} - 99pct: {} - 99.9pct: {} - 99.99pct: {} - Max: {}",
throughputFormat.format(rate), throughputFormat.format(throughput),
"Throughput produced: {} msg --- {} msg/s --- {} Mbit/s --- Latency: mean: {} ms - med: {} - 95pct: {} - 99pct: {} - 99.9pct: {} - 99.99pct: {} - Max: {}",
intFormat.format(total),
throughputFormat.format(rate),
throughputFormat.format(throughput),
dec.format(reportHistogram.getMean() / 1000.0),
dec.format(reportHistogram.getValueAtPercentile(50) / 1000.0),
dec.format(reportHistogram.getValueAtPercentile(95) / 1000.0),
Expand Down Expand Up @@ -408,5 +411,6 @@ private static void printAggregatedStats() {
static final DecimalFormat throughputFormat = new PaddingDecimalFormat("0.0", 8);
static final DecimalFormat dec = new PaddingDecimalFormat("0.000", 7);
static final DecimalFormat totalFormat = new DecimalFormat("0.000");
static final DecimalFormat intFormat = new PaddingDecimalFormat("0", 7);
private static final Logger log = LoggerFactory.getLogger(ManagedLedgerWriter.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@
import org.apache.pulsar.client.impl.MessageIdImpl;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.util.FutureUtil;
import org.apache.pulsar.testclient.utils.PaddingDecimalFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PerformanceReader {
private static final LongAdder messagesReceived = new LongAdder();
private static final LongAdder bytesReceived = new LongAdder();
private static final DecimalFormat intFormat = new PaddingDecimalFormat("0", 7);
private static final DecimalFormat dec = new DecimalFormat("0.000");

private static final LongAdder totalMessagesReceived = new LongAdder();
Expand Down Expand Up @@ -312,12 +314,14 @@ public static void main(String[] args) throws Exception {

long now = System.nanoTime();
double elapsed = (now - oldTime) / 1e9;
long total = totalMessagesReceived.sum();
double rate = messagesReceived.sumThenReset() / elapsed;
double throughput = bytesReceived.sumThenReset() / elapsed * 8 / 1024 / 1024;

reportHistogram = recorder.getIntervalHistogram(reportHistogram);
log.info(
"Read throughput: {} msg/s -- {} Mbit/s --- Latency: mean: {} ms - med: {} - 95pct: {} - 99pct: {} - 99.9pct: {} - 99.99pct: {} - Max: {}",
"Read throughput: {} msg --- {} msg/s -- {} Mbit/s --- Latency: mean: {} ms - med: {} - 95pct: {} - 99pct: {} - 99.9pct: {} - 99.99pct: {} - Max: {}",
intFormat.format(total),
dec.format(rate), dec.format(throughput), dec.format(reportHistogram.getMean()),
reportHistogram.getValueAtPercentile(50), reportHistogram.getValueAtPercentile(95),
reportHistogram.getValueAtPercentile(99), reportHistogram.getValueAtPercentile(99.9),
Expand Down

0 comments on commit 91697c5

Please sign in to comment.