You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/12/30 14:13:51 UTC
svn commit: r1819605 -
/jmeter/trunk/src/components/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java
Author: pmouawad
Date: Sat Dec 30 14:13:51 2017
New Revision: 1819605
URL: http://svn.apache.org/viewvc?rev=1819605&view=rev
Log:
Bug 61931 - Exponential Timer : timer that produces poisson arrivals with given constant throughput
Fix some sonar warnings
Bugzilla Id: 61931
Modified:
jmeter/trunk/src/components/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java
Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java?rev=1819605&r1=1819604&r2=1819605&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java Sat Dec 30 14:13:51 2017
@@ -33,10 +33,10 @@ public class ConstantPoissonProcessGener
private static final Logger log = LoggerFactory.getLogger(ConstantPoissonProcessGenerator.class);
private Random rnd = new Random();
- public ThroughputProvider throughput;
+ private ThroughputProvider throughputProvider;
private int batchSize;
private int batchThreadDelay;
- public DurationProvider duration;
+ private DurationProvider durationProvider;
private double lastThroughput;
private int exactLimit;
private double allowedThroughputSurplus;
@@ -48,10 +48,10 @@ public class ConstantPoissonProcessGener
ThroughputProvider throughput, int batchSize, int batchThreadDelay,
DurationProvider duration, int exactLimit, double allowedThroughputSurplus,
Long seed, boolean logFirstSamples) {
- this.throughput = throughput;
+ this.throughputProvider = throughput;
this.batchSize = batchSize;
this.batchThreadDelay = batchThreadDelay;
- this.duration = duration;
+ this.durationProvider = duration;
this.exactLimit = exactLimit;
this.allowedThroughputSurplus = allowedThroughputSurplus;
this.logFirstSamples = logFirstSamples;
@@ -62,7 +62,7 @@ public class ConstantPoissonProcessGener
}
private void ensureCapacity() {
- int size = (int) Math.round((throughput.getThroughput() * duration.getDuration() + 1) * 3);
+ int size = (int) Math.round((throughputProvider.getThroughput() * durationProvider.getDuration() + 1) * 3);
if (events != null && events.capacity() >= size) {
return;
}
@@ -70,19 +70,19 @@ public class ConstantPoissonProcessGener
}
public void generateNext() {
- double throughput = this.throughput.getThroughput();
+ double throughput = this.throughputProvider.getThroughput();
lastThroughput = throughput;
if (batchSize > 1) {
throughput /= batchSize;
}
- long duration = this.duration.getDuration();
+ long duration = this.durationProvider.getDuration();
ensureCapacity();
int samples = (int) Math.ceil(throughput * duration);
double time;
int i = 0;
long t = System.currentTimeMillis();
int loops = 0;
- double allowedThroughputSurplus = samples < exactLimit ? 0.0d : this.allowedThroughputSurplus / 100;
+ double currentAllowedThroughputSurplus = samples < exactLimit ? 0.0d : this.allowedThroughputSurplus / 100;
do {
time = 0;
events.clear();
@@ -104,7 +104,7 @@ public class ConstantPoissonProcessGener
loops++;
} while (System.currentTimeMillis() - t < 5000 &&
(i < samples + 1 // not enough samples
- || (i - 1 - samples) * 1.0f / samples > allowedThroughputSurplus));
+ || (i - 1 - samples) * 1.0f / samples > currentAllowedThroughputSurplus));
t = System.currentTimeMillis() - t;
if (t > 1000) {
log.warn("Spent {} ms while generating sequence of delays for {} samples, {} throughput, {} duration",
@@ -118,8 +118,8 @@ public class ConstantPoissonProcessGener
if(log.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Generated ").append(events.position()).append(" timings (");
- if (this.duration instanceof AbstractTestElement) {
- sb.append(((AbstractTestElement) this.duration).getName());
+ if (this.durationProvider instanceof AbstractTestElement) {
+ sb.append(((AbstractTestElement) this.durationProvider).getName());
}
sb.append(" ").append(samples).append(" required, rate ").append(throughput).append(", duration ").append(duration);
sb.append(", exact lim ").append(exactLimit).append(", i").append(i);
@@ -157,7 +157,7 @@ public class ConstantPoissonProcessGener
@Override
public double next() {
- if (!events.hasRemaining() || throughput.getThroughput() != lastThroughput) {
+ if (!events.hasRemaining() || throughputProvider.getThroughput() != lastThroughput) {
generateNext();
}
lastEvent = events.get();