Skip to content

Commit 7def5f4

Browse files
committed
Move DEFAULT_REPORTING_INTERVAL_MS into Stats
- Remove DEFAULT_REPORTING_INTERVAL_MS as a constructor parameter and move into Stats class; refactor Stats constructors to not use reportingInterval as a parameter - Remove DEBUG print statement
1 parent 4ff4daa commit 7def5f4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class ProducerPerformance {
5151

5252
public static final String DEFAULT_TRANSACTION_ID_PREFIX = "performance-producer-";
5353
public static final long DEFAULT_TRANSACTION_DURATION_MS = 3000L;
54-
public static final int DEFAULT_REPORTING_INTERVAL_MS = 5000;
5554

5655
public static void main(String[] args) throws Exception {
5756
ProducerPerformance perf = new ProducerPerformance();
@@ -77,12 +76,10 @@ void start(String[] args) throws IOException {
7776
SplittableRandom random = new SplittableRandom(0);
7877
ProducerRecord<byte[], byte[]> record;
7978

80-
System.out.println("DEBUG: config.warmupRecords=" + config.warmupRecords + ", (config.warmupRecords > 0)=" + (config.warmupRecords > 0));
81-
8279
if (config.warmupRecords > 0) {
8380
System.out.println("Warmup first " + config.warmupRecords + " records. Steady state results will print after the complete test summary.");
8481
}
85-
stats = new Stats(config.numRecords, DEFAULT_REPORTING_INTERVAL_MS);
82+
stats = new Stats(config.numRecords);
8683
long startMs = System.currentTimeMillis();
8784

8885
ThroughputThrottler throttler = new ThroughputThrottler(config.throughput, startMs);
@@ -102,7 +99,7 @@ record = new ProducerRecord<>(config.topicName, payload);
10299

103100
long sendStartMs = System.currentTimeMillis();
104101
if ( config.warmupRecords > 0 && i == config.warmupRecords ) {
105-
steadyStateStats = new Stats(config.numRecords - config.warmupRecords, DEFAULT_REPORTING_INTERVAL_MS, config.warmupRecords > 0);
102+
steadyStateStats = new Stats(config.numRecords - config.warmupRecords, config.warmupRecords > 0);
106103
stats.steadyStateActive = true;
107104
}
108105
cb = new PerfCallback(sendStartMs, payload.length, stats, steadyStateStats);
@@ -378,11 +375,11 @@ static class Stats {
378375
private final boolean isSteadyState;
379376
private boolean steadyStateActive;
380377

381-
public Stats(long numRecords, int reportingInterval) {
382-
this(numRecords, reportingInterval, false);
378+
public Stats(long numRecords) {
379+
this(numRecords, false);
383380
}
384381

385-
public Stats(long numRecords, int reportingInterval, boolean isSteadyState) {
382+
public Stats(long numRecords, boolean isSteadyState) {
386383
this.start = System.currentTimeMillis();
387384
this.windowStart = System.currentTimeMillis();
388385
this.iteration = 0;
@@ -395,7 +392,7 @@ public Stats(long numRecords, int reportingInterval, boolean isSteadyState) {
395392
this.windowTotalLatency = 0;
396393
this.windowBytes = 0;
397394
this.totalLatency = 0;
398-
this.reportingInterval = reportingInterval;
395+
this.reportingInterval = 5000;
399396
this.isSteadyState = isSteadyState;
400397
this.steadyStateActive = isSteadyState;
401398
}

0 commit comments

Comments
 (0)