-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timer : Add a factor to apply on pauses #4069
Comments
Sebb (migrated from Bugzilla): Most (all?) the timers can take variables, so it's possible to implement this anyway. |
UbikLoadPack support (migrated from Bugzilla): This frequently happens at the beginning of a campaign when you're trying to find the good think times to reach some load and you don't want to increase threads. Yes it can be done by using __BeanShell or __groovy to use a property containing factor but whenever you have different think times between the samplers (We use TestAction with pause time at 0 and its child is a Timer) in a realistic test plan, it becomes a lot of work and makes test plan harder to maintain. It's not a big piece of code (1 line in JMeterThread#delay ) and it's only a matter of adding a property:
Regards |
benoit.wiart (migrated from Bugzilla): I also think timers should be moved out of the sampler and become "first level" elements. |
Sebb (migrated from Bugzilla):
Also documentation, testing. Every additional function increases user support costs somewhat.
|
@pmouawad (migrated from Bugzilla):
If this contributor contributes the full feature that they find useful, why would be refuse it ? I don't share the reasoning regarding additional function.
|
Sebb (migrated from Bugzilla):
I was just pointing out that the amount of work involved is more than you wrote. When deciding whether to implement a new feature, it's important to do a cost-benefit analysis. Ignoring some of the cost invalidates the analysis.
That does not follow from what I wrote. |
@vlsi (migrated from Bugzilla): I think the following approach should be used:
ULP>reach some load and you don't want to increase threads. Suppose we are dealing with callcenter of 20 operators. We specify 20 threads. Does it make sense? |
UbikLoadPack support (migrated from Bugzilla):
If you read http://jmeter.apache.org/usermanual/component_reference.html#Constant_Throughput_Timer, Of course the throughput will be lower if the server is not capable of handling it, or if >>>>other timers<<<< or time-consuming test elements prevent it.
Yes. Isn't it interesting to be able to validate the hypothesis by multiplying all pause times (except CTP (read below proposition)) by a double (not int) factor and test again ? instead of having to do that in scripting. We could implement it this way:
Also, as noted by Antonio Gomes Rodrigues in mailing list, this feature exists in alternative products in the same field, so it must be useful no ? Regards |
UbikLoadPack support (migrated from Bugzilla):
The patch is already usable like this and it was very useful during a load testing campaign this week to adjust timer and reach a behaviour similar to production. Next step can be:
Regards Created attachment BUG_60018.patch: Patch implementing first part of the feature BUG_60018.patchIndex: bin/jmeter.properties
===================================================================
--- bin/jmeter.properties (revision 1759038)
+++ bin/jmeter.properties (working copy)
@@ -1242,3 +1242,7 @@
# Number of iterations to use to validate a Thread Group
#testplan_validation.number_iterations=1
+
+# Timer factor that can be applied to Timer except for Constant ThroughputTimer and SynchronizingTimer
+# as long as any timer return false in org.apache.jmeter.timers.Timer#isModifiable
+#timer.factor=1.0
\ No newline at end of file
Index: src/components/org/apache/jmeter/timers/BSFTimer.java
===================================================================
--- src/components/org/apache/jmeter/timers/BSFTimer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/BSFTimer.java (working copy)
@@ -52,4 +52,9 @@
}
return delay;
}
+
+ @Override
+ public boolean isModifiable() {
+ return true;
+ }
}
Index: src/components/org/apache/jmeter/timers/BeanShellTimer.java
===================================================================
--- src/components/org/apache/jmeter/timers/BeanShellTimer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/BeanShellTimer.java (working copy)
@@ -62,4 +62,9 @@
return 0;
}
}
+
+ @Override
+ public boolean isModifiable() {
+ return true;
+ }
}
Index: src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java
===================================================================
--- src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java (working copy)
@@ -217,8 +217,8 @@
//Synchronize on the info object's MUTEX to ensure
//Multiple threads don't update the scheduled time simultaneously
synchronized (info.MUTEX) {
- final long nextRequstTime = info.lastScheduledTime + milliSecPerRequest;
- info.lastScheduledTime = Math.max(now, nextRequstTime);
+ final long nextRequestTime = info.lastScheduledTime + milliSecPerRequest;
+ info.lastScheduledTime = Math.max(now, nextRequestTime);
calculatedDelay = info.lastScheduledTime - now;
}
@@ -329,5 +329,9 @@
void setMode(Mode newMode) {
mode = newMode;
}
-
+
+ @Override
+ public boolean isModifiable() {
+ return false;
+ }
}
Index: src/components/org/apache/jmeter/timers/ConstantTimer.java
===================================================================
--- src/components/org/apache/jmeter/timers/ConstantTimer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/ConstantTimer.java (working copy)
@@ -109,4 +109,9 @@
delay = getPropertyAsLong(DELAY);
}
+
+ @Override
+ public boolean isModifiable() {
+ return true;
+ }
}
Index: src/components/org/apache/jmeter/timers/JSR223Timer.java
===================================================================
--- src/components/org/apache/jmeter/timers/JSR223Timer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/JSR223Timer.java (working copy)
@@ -50,4 +50,9 @@
}
return delay;
}
+
+ @Override
+ public boolean isModifiable() {
+ return true;
+ }
}
Index: src/components/org/apache/jmeter/timers/SyncTimer.java
===================================================================
--- src/components/org/apache/jmeter/timers/SyncTimer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/SyncTimer.java (working copy)
@@ -275,4 +275,9 @@
public void setTimeoutInMs(long timeoutInMs) {
this.timeoutInMs = timeoutInMs;
}
+
+ @Override
+ public boolean isModifiable() {
+ return false;
+ }
}
Index: src/components/org/apache/jmeter/timers/UniformRandomTimer.java
===================================================================
--- src/components/org/apache/jmeter/timers/UniformRandomTimer.java (revision 1754657)
+++ src/components/org/apache/jmeter/timers/UniformRandomTimer.java (working copy)
@@ -20,7 +20,7 @@
import java.io.Serializable;
-import org.apache.jmeter.util.JMeterUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* This class implements those methods needed by RandomTimer to be instantiable
@@ -38,7 +38,7 @@
@Override
public String toString() {
- return JMeterUtils.getResString("uniform_timer_memo"); //$NON-NLS-1$
+ //return JMeterUtils.getResString("uniform_timer_memo"); //$NON-NLS-1$
+ return ToStringBuilder.reflectionToString(this);
}
-
}
Index: src/core/org/apache/jmeter/threads/JMeterThread.java
===================================================================
--- src/core/org/apache/jmeter/threads/JMeterThread.java (revision 1758348)
+++ src/core/org/apache/jmeter/threads/JMeterThread.java (working copy)
@@ -75,6 +75,8 @@
private static final int RAMPUP_GRANULARITY =
JMeterUtils.getPropDefault("jmeterthread.rampup.granularity", 1000); // $NON-NLS-1$
+ private static final double TIMER_FACTOR = JMeterUtils.getPropDefault("timer.factor", 1.0d);
+
private final Controller threadGroupLoopController;
private final HashTree testTree;
@@ -795,7 +797,17 @@
long totalDelay = 0;
for (Timer timer : timers) {
TestBeanHelper.prepare((TestElement) timer);
- totalDelay += timer.delay();
+ long delay = timer.delay();
+ if(TIMER_FACTOR != 1.0d && timer.isModifiable()) {
+ if(log.isDebugEnabled()) {
+ log.debug("Applying TIMER_FACTOR:"
+ +TIMER_FACTOR + " on timer:"
+ +((TestElement)timer).getName()
+ + " for thread:"+getThreadName());
+ }
+ delay = Math.round(delay * TIMER_FACTOR);
+ }
+ totalDelay += delay;
}
if (totalDelay > 0) {
try {
Index: src/core/org/apache/jmeter/timers/Timer.java
===================================================================
--- src/core/org/apache/jmeter/timers/Timer.java (revision 1754657)
+++ src/core/org/apache/jmeter/timers/Timer.java (working copy)
@@ -33,4 +33,9 @@
* @return the computed delay value.
*/
long delay();
+
+ /**
+ * @return true if factor can be applied to it
+ */
+ boolean isModifiable();
}
Index: src/core/org/apache/jmeter/util/JMeterUtils.java
===================================================================
--- src/core/org/apache/jmeter/util/JMeterUtils.java (revision 1756527)
+++ src/core/org/apache/jmeter/util/JMeterUtils.java (working copy)
@@ -856,6 +856,26 @@
}
return ans;
}
+
+ /**
+ * Get a double value with default if not present.
+ *
+ * @param propName
+ * the name of the property.
+ * @param defaultVal
+ * the default value.
+ * @return The PropDefault value
+ */
+ public static double getPropDefault(String propName, double defaultVal) {
+ double ans;
+ try {
+ ans = Double.parseDouble(appProperties.getProperty(propName, Double.toString(defaultVal)).trim());
+ } catch (Exception e) {
+ log.warn("Exception '"+ e.getMessage()+ "' occurred when fetching double property:'"+propName+"', defaulting to:"+defaultVal);
+ ans = defaultVal;
+ }
+ return ans;
+ }
/**
* Get a String value with default if not present. |
@pmouawad (migrated from Bugzilla): URL: http://svn.apache.org/viewvc?rev=1761563&view=rev Added: Author: pmouawad URL: http://svn.apache.org/viewvc?rev=1761564&view=rev Modified: |
@pmouawad (migrated from Bugzilla): URL: http://svn.apache.org/viewvc?rev=1762223&view=rev Modified: |
@pmouawad (migrated from Bugzilla): URL: http://svn.apache.org/viewvc?rev=1775911&view=rev Modified: Author: pmouawad URL: http://svn.apache.org/viewvc?rev=1775901&view=rev Modified: |
UbikLoadPack support (Bug 60018):
This bug is related partly to #3809
Sometimes you have to adapt the timers values to be half or double what they are currently.
When you have configured timers at every place this can be cumbersome as you have to touch tens of Test Elements.
It would be nice to be able to say: Take current computed pauses and multiply them by a factor.
Any other idea is welcome
If you agree to this idea, we can submit a patch.
Regards
@ubikloadpack
OS: All
Duplicates:
The text was updated successfully, but these errors were encountered: