org.apache.jmeter.timers

## Class ConstantThroughputTimer

- java.lang.Object
- - org.apache.jmeter.testelement.AbstractTestElement
  - - org.apache.jmeter.timers.ConstantThroughputTimer

- All Implemented Interfaces:
    Serializable, Cloneable, Searchable, TestBean, TestElement, TestStateListener, Timer

      public class ConstantThroughputTimer
      extends AbstractTestElement
      implements Timer, TestStateListener, TestBean

  This class implements a constant throughput timer. A Constant Throughput Timer paces the samplers under its influence so that the total number of samples per unit of time approaches a given constant as much as possible. There are two different ways of pacing the requests: - delay each thread according to when it last ran - delay each thread according to when any thread last ran
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ConstantThroughputTimer.Mode` This enum defines the calculation modes used by the ConstantThroughputTimer.

  - ### Field Summary

    - ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

      `COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConstantThroughputTimer()` Constructor for a non-configured ConstantThroughputTimer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected long` | `calculateCurrentTarget(long currentTime)` Calculate the target time by adding the result of private method `calculateDelay()` to the given `currentTime`
    `long` | `delay()` Retrieve the delay to use during test execution.
    `int` | `getCalcMode()`
    `double` | `getThroughput()` Gets the configured desired throughput.
    `void` | `setCalcMode(int mode)`
    `void` | `setProperty(JMeterProperty property)` Override the setProperty method in order to convert the original String calcMode property.
    `void` | `setThroughput(double throughput)` Sets the desired throughput.
    `void` | `testEnded()` Called once for all threads after the end of a test.
    `void` | `testEnded(String host)` Called once for all threads after the end of a test.
    `void` | `testStarted()` Get the timer ready to compute delays for a new test.
    `void` | `testStarted(String host)` Called just before the start of the test from the main engine thread.
    `String` | `toString()` Provide a description of this timer class.

    - ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

      `addPropertiesValues, addProperty, addProperty, addTestElement, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.jmeter.timers.Timer

      `isModifiable`

    - ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

      `removed`

- - ### Constructor Detail

    - #### ConstantThroughputTimer

          public ConstantThroughputTimer()

      Constructor for a non-configured ConstantThroughputTimer.

  - ### Method Detail

    - #### setThroughput

          public void setThroughput(double throughput)

      Sets the desired throughput.
      Parameters:
        `throughput` - Desired sampling rate, in samples per minute.

    - #### getThroughput

          public double getThroughput()

      Gets the configured desired throughput.
      Returns:
        the rate at which samples should occur, in samples per minute.

    - #### getCalcMode

          public int getCalcMode()

    - #### setCalcMode

          public void setCalcMode(int mode)

    - #### delay

          public long delay()

      Retrieve the delay to use during test execution.
      Specified by:
        `delay` in interface `Timer`
      Returns:
        the computed delay value.
      See Also:
        `Timer.delay()`

    - #### calculateCurrentTarget

          protected long calculateCurrentTarget(long currentTime)

      Calculate the target time by adding the result of private method `calculateDelay()` to the given `currentTime`
      Parameters:
        `currentTime` - time in ms
      Returns:
        new Target time

    - #### toString

          public String toString()

      Provide a description of this timer class. TODO: Is this ever used? I can't remember where. Remove if it isn't -- TODO: or obtain text from bean's displayName or shortDescription.
      Overrides:
        `toString` in class `Object`
      Returns:
        the description of this timer class.

    - #### testStarted

          public void testStarted()

      Get the timer ready to compute delays for a new test.

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testStarted` in interface `TestStateListener`
      See Also:
        `StandardJMeterEngine.run()`

    - #### setProperty

          public void setProperty(JMeterProperty property)

      Override the setProperty method in order to convert the original String calcMode property. This used the locale-dependent display value, so caused problems when the language was changed. Note that the calcMode StringProperty is replaced with an IntegerProperty so the conversion only needs to happen once.
      Specified by:
        `setProperty` in interface `TestElement`
      Overrides:
        `setProperty` in class `AbstractTestElement`
      Parameters:
        `property` - the property to be set

    - #### testEnded

          public void testEnded()

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testEnded` in interface `TestStateListener`
      See Also:
        `StandardJMeterEngine.stopTest()`

    - #### testStarted

          public void testStarted(String host)

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testStarted` in interface `TestStateListener`
      Parameters:
        `host` - name of host
      See Also:
        `StandardJMeterEngine.run()`

    - #### testEnded

          public void testEnded(String host)

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testEnded` in interface `TestStateListener`
      Parameters:
        `host` - name of host
      See Also:
        `StandardJMeterEngine.stopTest()`

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.