public class RpsThreadGroup extends BaseThreadGroup<RpsThreadGroup>
Warning: by default the thread group uses unbounded maximum number of threads, but this
is not a good practice since it might impose unexpected load on load generator (CPU or memory may
run out). It is advisable to always set a maximum number of threads. Check
maxThreads(int).
Internally this element uses Concurrency Thread Group in combination with Throughput Shaping Timer.
By default, the thread group will control the number of requests per second, but this can be
changed to iterations per second with counting(EventType).
| Modifier and Type | Class and Description |
|---|---|
static class |
RpsThreadGroup.EventType |
static class |
RpsThreadGroup.TimerSchedule |
BaseThreadGroup.SampleErrorAction, BaseThreadGroup.ThreadGroupChild| Modifier and Type | Field and Description |
|---|---|
protected RpsThreadGroup.EventType |
counting |
protected int |
initThreads |
protected double |
lastRps |
protected int |
maxThreads |
protected List<RpsThreadGroup.TimerSchedule> |
schedules |
protected double |
spareThreads |
sampleErrorActionchildrenguiClass, name| Constructor and Description |
|---|
RpsThreadGroup(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.jmeter.threads.AbstractThreadGroup |
buildThreadGroup() |
org.apache.jorphan.collections.HashTree |
buildTreeUnder(org.apache.jorphan.collections.HashTree parent,
BuildTreeContext context)
Builds the JMeter HashTree for this TestElement under the provided tree node.
|
RpsThreadGroup |
counting(RpsThreadGroup.EventType counting)
Specifies to either control requests or iterations per second.
|
RpsThreadGroup |
holdFor(Duration duration)
Specifies to keep current RPS for a given duration.
|
RpsThreadGroup |
initThreads(int initThreads)
Specifies the initial number of threads to use.
|
RpsThreadGroup |
maxThreads(int maxThreads)
Specifies the maximum number of threads to use.
|
RpsThreadGroup |
rampTo(double rps,
Duration duration)
Allows ramping up or down RPS with a given duration.
|
RpsThreadGroup |
rampToAndHold(double rps,
Duration rampDuration,
Duration holdDuration)
Simply combines
rampTo(double, Duration) and holdFor(Duration) which are
usually used in combination. |
void |
showTimeline() |
RpsThreadGroup |
spareThreads(double spareThreads)
Specifies the number of spare (not used) threads to keep in the thread group.
|
buildTestElement, children, sampleErrorActionbuildConfiguredTestElement, buildTestElementGui, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitshowInGuiprotected final List<RpsThreadGroup.TimerSchedule> schedules
protected double lastRps
protected RpsThreadGroup.EventType counting
protected int initThreads
protected int maxThreads
protected double spareThreads
public RpsThreadGroup(String name)
public RpsThreadGroup rampTo(double rps, Duration duration)
JMeter will automatically create or remove threads from thread group and add time pauses to match provided RPS.
You can use this method multiple times in a thread group and in conjunction with
holdFor(Duration) and rampToAndHold(double, Duration, Duration) to elaborate
complex test plan profiles.
Eg:
rpsThreadGroup()
.maxThreads(10)
.rampTo(10, Duration.ofSeconds(10))
.rampTo(5, Duration.ofSeconds(10))
.rampToAndHold(20, Duration.ofSeconds(5), Duration.ofSeconds(10))
.rampTo(0, Duration.ofSeconds(5))
.children(...)
rps - specifies the final RPS (requests/iterations per second) after the given
period. This value directly affects how often threads and pauses are adjusted.
For example, if you configure a ramp from 0.01 to 10 RPS with 10 seconds
duration, after 1 request it will wait 100 seconds and then reevaluate, not
honoring configured ramp. A value greater than 1 should at least re adjust
every second.duration - duration taken to reach the given RPS and move to the next stage or end the
test plan. Since JMeter only supports specifying times in seconds, if you
specify a smaller granularity (like milliseconds) it will be rounded up to
seconds.public RpsThreadGroup holdFor(Duration duration)
This method is usually used in combination with rampTo(double, Duration) to define the
profile of the test plan.
duration - duration to hold the current RPS until moving to next stage or ending the test
plan. Since JMeter only supports specifying times in seconds, if you specify a
smaller granularity (like milliseconds) it will be rounded up to seconds.rampTo(double, Duration)public RpsThreadGroup rampToAndHold(double rps, Duration rampDuration, Duration holdDuration)
rampTo(double, Duration) and holdFor(Duration) which are
usually used in combination.rps - target RPS to ramp up/down to. This value directly affects how often
threads and pauses are adjusted. For example, if you configure a ramp from
0.01 to 10 RPS with 10 seconds duration, after 1 request it will wait 100
seconds and then reevaluate, not honoring configured ramp. A value greater
than 1 should at least re adjust every second.rampDuration - duration taken to reach the given RPS.holdDuration - duration to hold the given RPS after the ramp, until moving to next stage
or ending the test plan.rampTo(double, Duration),
holdFor(Duration)public RpsThreadGroup counting(RpsThreadGroup.EventType counting)
If you are only concerned on controlling the number of requests per second, then there is no need to use this method since this is the default behavior. On the other hand, if you actually want to control how many times per second the flow inside the thread group executes, then you can use this method counting iterations.
counting - specifies what event type to use to control the RPS. When not specified
requests are counted.public RpsThreadGroup maxThreads(int maxThreads)
Warning: this value should be big enough to be able to reach the maximum desired RPS,
otherwise the maximum RPS will not be able to be met. If you have requests that have maximum
response time (or iteration time, if you are counting iteration instead of requests, see:
counting(EventType)) R seconds, and need to reach T maximum RPS, then you should set
this value to R*T.
Warning: by default, maximum threads are unbounded, but this means that you may run out of memory or consume too much CPU. Is a good practice to always set this value to avoid unexpected load on generator that may affect performance test in some undesired ways.
maxThreads - specifies the maximum threads to use by the thread group. By default, is
unbounded.public RpsThreadGroup initThreads(int initThreads)
Use this method to start with a bigger pool if you know beforehand that for inital RPS 1 thread would not be enough.
initThreads - specifies the initial number of threads to use by the thread group. By
default, is 1.public RpsThreadGroup spareThreads(double spareThreads)
When thread group identifies that can use less threads, it can still keep them in pool to avoid the cost to re-create them later on if needed. This method controls how many threads to keep.
spareThreads - specifies either the number of spare threads (if the value is greater than
1) or the percent (if <= 1) from the current active threads count. By
default, is 0.1 (10% of active threads).public org.apache.jorphan.collections.HashTree buildTreeUnder(org.apache.jorphan.collections.HashTree parent,
BuildTreeContext context)
DslTestElementbuildTreeUnder in interface DslTestElementbuildTreeUnder in class TestElementContainer<RpsThreadGroup,BaseThreadGroup.ThreadGroupChild>parent - the node which will be the parent for the created tree.context - context information which contains information shared by elements while building
the test plan tree (eg: adding additional items to test plan when a particular protocol element
is added).protected org.apache.jmeter.threads.AbstractThreadGroup buildThreadGroup()
buildThreadGroup in class BaseThreadGroup<RpsThreadGroup>public void showTimeline()
Copyright © 2024. All rights reserved.