Class RpsThreadGroup

    • Constructor Detail

      • RpsThreadGroup

        public RpsThreadGroup​(String name)
    • Method Detail

      • rampTo

        public RpsThreadGroup rampTo​(double rps,
                                     Duration duration)
        Allows ramping up or down RPS with a given 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(...)
         
        Parameters:
        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.
        Returns:
        the thread group for further configuration and usage.
      • holdFor

        public RpsThreadGroup holdFor​(Duration duration)
        Specifies to keep current RPS for a given duration.

        This method is usually used in combination with rampTo(double, Duration) to define the profile of the test plan.

        Parameters:
        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.
        Returns:
        the thread group for further configuration and usage.
        See Also:
        rampTo(double, Duration)
      • rampToAndHold

        public RpsThreadGroup rampToAndHold​(double rps,
                                            Duration rampDuration,
                                            Duration holdDuration)
        Simply combines rampTo(double, Duration) and holdFor(Duration) which are usually used in combination.
        Parameters:
        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.
        Returns:
        the thread group for further configuration and usage.
        See Also:
        rampTo(double, Duration), holdFor(Duration)
      • counting

        public RpsThreadGroup counting​(RpsThreadGroup.EventType counting)
        Specifies to either control requests or iterations per second.

        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.

        Parameters:
        counting - specifies what event type to use to control the RPS. When not specified requests are counted.
        Returns:
        the thread group for further configuration and usage.
      • maxThreads

        public RpsThreadGroup maxThreads​(int maxThreads)
        Specifies the maximum number of threads to use.

        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.

        Parameters:
        maxThreads - specifies the maximum threads to use by the thread group. By default, is unbounded.
        Returns:
        the thread group for further configuration and usage.
      • initThreads

        public RpsThreadGroup initThreads​(int initThreads)
        Specifies the initial number of threads to use.

        Use this method to start with a bigger pool if you know beforehand that for inital RPS 1 thread would not be enough.

        Parameters:
        initThreads - specifies the initial number of threads to use by the thread group. By default, is 1.
        Returns:
        the thread group for further configuration and usage.
      • spareThreads

        public RpsThreadGroup spareThreads​(double spareThreads)
        Specifies the number of spare (not used) threads to keep in the thread group.

        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.

        Parameters:
        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).
        Returns:
        the thread group for further configuration and usage.
      • buildTreeUnder

        public org.apache.jorphan.collections.HashTree buildTreeUnder​(org.apache.jorphan.collections.HashTree parent,
                                                                      BuildTreeContext context)
        Description copied from interface: DslTestElement
        Builds the JMeter HashTree for this TestElement under the provided tree node.
        Specified by:
        buildTreeUnder in interface DslTestElement
        Overrides:
        buildTreeUnder in class TestElementContainer<RpsThreadGroup,​BaseThreadGroup.ThreadGroupChild>
        Parameters:
        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).
        Returns:
        The tree created under the parent node.
      • showTimeline

        public void showTimeline()
        Shows a graph with a timeline of planned rps count execution for this test plan.

        The graph will be displayed in a popup window.

        This method is provided mainly to ease test plan designing when working with complex thread group profiles (several stages with ramps and holds).

        Since:
        0.26